示例#1
0
        public bool InitWithString(string theString, string fntFile)
        {
            string data = CCFileUtils.GetFileData(fntFile);

            PlistDocument doc = new PlistDocument(data);
            var dict = doc.Root as PlistDictionary;

            Debug.Assert(dict["version"].AsInt == 1, "Unsupported version. Upgrade cocos2d version");

            string textureFilename = dict["textureFilename"].AsString;
            int width = dict["itemWidth"].AsInt / CCMacros.CCContentScaleFactor();
            int height = dict["itemHeight"].AsInt / CCMacros.CCContentScaleFactor();
            var startChar = (char) dict["firstChar"].AsInt;

            return InitWithString(theString, textureFilename, width, height, startChar);
        }
示例#2
0
        public BMFontUnicode()
        {
            var data = CCFileUtils.GetFileData("fonts/strings.plist");
            PlistDocument doc = new PlistDocument(data);
            var strings = doc.Root as PlistDictionary;

            string chinese = strings["chinese1"].AsString;
            string japanese = strings["japanese"].AsString;
            string spanish = strings["spanish"].AsString;

            label1 = new CCLabelBMFont(spanish, "fonts/arial-unicode-26.fnt", 200, CCTextAlignment.Left);
            AddChild(label1);

            label2 = new CCLabelBMFont(chinese, "fonts/arial-unicode-26.fnt");
            AddChild(label2);

            label3 = new CCLabelBMFont(japanese, "fonts/arial-unicode-26.fnt");
            AddChild(label3);
        }
示例#3
0
        public BMFontUnicode()
        {
            var data = CCFileUtils.GetFileData("fonts/strings.plist");
            PlistDocument doc = new PlistDocument(data);
            var strings = doc.Root as PlistDictionary;

            string chinese = strings["chinese1"].AsString;
            string japanese = strings["japanese"].AsString;
            string spanish = strings["spanish"].AsString;

            CCSize s = CCDirector.SharedDirector.WinSize;

            CCLabelBMFont label1 = new CCLabelBMFont(spanish, "fonts/arial-unicode-26.fnt", 200, CCTextAlignment.Left);
            AddChild(label1);
            label1.Position = new CCPoint(s.Width / 2, s.Height / 4 * 3);

            CCLabelBMFont label2 = new CCLabelBMFont(chinese, "fonts/arial-unicode-26.fnt");
            AddChild(label2);
            label2.Position = new CCPoint(s.Width / 2, s.Height / 4 * 2);

            CCLabelBMFont label3 = new CCLabelBMFont(japanese, "fonts/arial-unicode-26.fnt");
            AddChild(label3);
            label3.Position = new CCPoint(s.Width / 2, s.Height / 4 * 1);
        }
        public LabelFNTUNICODELanguages()
        {
            var data = CCFileUtils.GetFileData("fonts/strings.plist");
            PlistDocument doc = new PlistDocument(data);
            var strings = doc.Root as PlistDictionary;

            var chinese = strings["chinese1"].AsString;
            var japanese = strings["japanese"].AsString;
            var spanish = strings["spanish"].AsString;
            var russian = strings["russian"].AsString;

            label1 = new CCLabel(spanish, "fonts/arial-unicode-26.fnt", new CCSize(200,0), CCLabelFormat.BitMapFont);
            label1.LabelFormat.Alignment = CCTextAlignment.Center;
            AddChild(label1);

            label2 = new CCLabel(chinese, "fonts/arial-unicode-26.fnt");
            AddChild(label2);

            label3 = new CCLabel(russian, "fonts/arial-26-en-ru.fnt");
            AddChild(label3);

            label4 = new CCLabel(japanese, "fonts/arial-unicode-26.fnt");
            AddChild(label4);
        }
示例#5
0
        private void LoadSheetData(SheetData sheetData)
        {
            var texture = Game.Content.Load<Texture2D> (sheetData.Texture);
            var stream = TitleContainer.OpenStream(sheetData.PList);

            #if __IOS__
            PlistDocument pinfo = new PlistDocument(stream);
            PlistDictionary frames = pinfo.Root.AsDictionary["frames"].AsDictionary;

            foreach (var frame in frames) {
                string spriteName = frame.Key.Split('.')[0];
                string texRect = frame.Value.AsDictionary["frame"].AsString;
                var sp = new Sprite2D (spriteName, texture, RectangleFromString (texRect), sheetData.FrameWidth, sheetData.FrameHeight);
                m_sprites.Add (spriteName, sp);
            }
            #else
            PList pinfo = new PList (stream);
            PList frames = pinfo ["frames"] as PList;

            foreach (var frmName in frames.Keys) {
                PList frame = frames [frmName] as PList;
                string texRect = frame ["frame"] as string;
                string spriteName = frmName.Split('.')[0];
                var sp = new Sprite2D (spriteName, texture, RectangleFromString (texRect), sheetData.FrameWidth, sheetData.FrameHeight);
                m_sprites.Add (spriteName, sp);
            }
            #endif
        }
        private static void SetUiBackgroundModes(PlistDocument plistDocument)
        {
            var backgroundModesArray = plistDocument.root.CreateArray("UIBackgroundModes");

            backgroundModesArray.AddString("remote-notification");
        }
示例#7
0
        public void InitWithStream(Stream stream, CCTexture2D texture)
        {
            var document = new PlistDocument();
            try
            {
                document.LoadFromXmlFile(stream);
            }
            catch (Exception)
            {
                throw (new Microsoft.Xna.Framework.Content.ContentLoadException("Failed to load the sprite sheet definition file from stream"));
            }

            PlistDictionary dict = document.Root.AsDictionary;

            InitWithDictionary(dict, texture);
        }
    private static void OnPostprocessBuildIOS(string pathToBuiltProject)
    {
        // We use UnityEditor.iOS.Xcode API which only exists in iOS editor module
#if UNITY_IOS
        string projPath = pathToBuiltProject + "/Unity-iPhone.xcodeproj/project.pbxproj";

        UnityEditor.iOS.Xcode.PBXProject proj = new UnityEditor.iOS.Xcode.PBXProject();
        proj.ReadFromString(File.ReadAllText(projPath));
        proj.AddFrameworkToProject(proj.TargetGuidByName("Unity-iPhone"), "ARKit.framework", false);
        string target = proj.TargetGuidByName("Unity-iPhone");
        Directory.CreateDirectory(Path.Combine(pathToBuiltProject, "Libraries/Unity"));

        // Check UnityARKitPluginSettings
        UnityARKitPluginSettings ps = LoadSettings();
        string        plistPath     = Path.Combine(pathToBuiltProject, "Info.plist");
        PlistDocument plist         = new PlistDocument();
        plist.ReadFromString(File.ReadAllText(plistPath));
        PlistElementDict rootDict = plist.root;

        // Get or create array to manage device capabilities
        const string      capsKey = "UIRequiredDeviceCapabilities";
        PlistElementArray capsArray;
        PlistElement      pel;
        if (rootDict.values.TryGetValue(capsKey, out pel))
        {
            capsArray = pel.AsArray();
        }
        else
        {
            capsArray = rootDict.CreateArray(capsKey);
        }
        // Remove any existing "arkit" plist entries
        const string arkitStr = "arkit";
        capsArray.values.RemoveAll(x => arkitStr.Equals(x.AsString()));
        if (ps.AppRequiresARKit)
        {
            // Add "arkit" plist entry
            capsArray.AddString(arkitStr);
        }

        const string shareString = "UIFileSharingEnabled";
        rootDict.SetBoolean(shareString, true);

        File.WriteAllText(plistPath, plist.WriteToString());

        foreach (ARReferenceImagesSet ar in imageSets)
        {
            AddReferenceImagesSetToAssetCatalog(ar, pathToBuiltProject, proj);
        }

        foreach (ARReferenceObjectsSetAsset objSet in objectSets)
        {
            AddReferenceObjectsSetAssetToStreamingAssets(objSet, pathToBuiltProject);
        }

        //TODO: remove this when XCode actool is able to handles ARResources despite deployment target
        if (imageSets.Count > 0)
        {
            proj.SetBuildProperty(target, "IPHONEOS_DEPLOYMENT_TARGET", "12.1");
        }

        // Add or replace define for facetracking
        UpdateDefinesInFile(pathToBuiltProject + "/Classes/Preprocessor.h", new Dictionary <string, bool>()
        {
            { "ARKIT_USES_FACETRACKING", ps.m_ARKitUsesFacetracking }
        });

        string[] filesToCopy = new string[]
        {
        };

        for (int i = 0; i < filesToCopy.Length; ++i)
        {
            var srcPath      = Path.Combine("../PluginSource/source", filesToCopy[i]);
            var dstLocalPath = "Libraries/" + filesToCopy[i];
            var dstPath      = Path.Combine(pathToBuiltProject, dstLocalPath);
            File.Copy(srcPath, dstPath, true);
            proj.AddFileToBuild(target, proj.AddFile(dstLocalPath, dstLocalPath));
        }

        File.WriteAllText(projPath, proj.WriteToString());
#endif // #if UNITY_IOS
    }
示例#9
0
    public static void OnPostprocessBuild(BuildTarget BuildTarget, string path)
    {
        #if UNITY_IOS
        // Get plist
        string        plistPath = path + "/Info.plist";
        PlistDocument plist     = new PlistDocument();
        plist.ReadFromString(File.ReadAllText(plistPath));
        // Get root
        PlistElementDict rootDict = plist.root;
        // Set encryption usage boolean
        string encryptKey = "ITSAppUsesNonExemptEncryption";
        rootDict.SetBoolean(encryptKey, false);
        // remove exit on suspend if it exists.
        string exitsOnSuspendKey = "UIApplicationExitsOnSuspend";
        if (rootDict.values.ContainsKey(exitsOnSuspendKey))
        {
            rootDict.values.Remove(exitsOnSuspendKey);
        }
        // Write to file
        File.WriteAllText(plistPath, plist.WriteToString());
    #endif
        // if (BuildTarget == BuildTarget.iOS)
        // {
        //     string projPath = PBXProject.GetPBXProjectPath(path);
        //     PBXProject proj = new PBXProject();
        //     proj.ReadFromString(File.ReadAllText(projPath));

        //     // 获取当前项目名字
        //     string target = proj.TargetGuidByName(PBXProject.GetUnityTargetName());

        //     // 对所有的编译配置设置选项
        //     proj.SetBuildProperty(target, "GCC_C_LANGUAGE_STANDARD", "gnu99");//为e2wsdk添加的
        //     proj.SetBuildProperty(target, "ENABLE_BITCODE", "NO");//为友盟添加的
        //     proj.SetBuildProperty(target, "DEBUG_INFORMATION_FORMAT", "DWARF");//debug模式不卡死

        //     // 添加依赖库
        //     // 语音sdk
        //     //proj.AddFrameworkToProject(target, "Security.framework", false);
        //     // システムのフレームワークを追加
        //     proj.AddFrameworkToProject(target, "CoreTelephony.framework", false);
        //     proj.AddFrameworkToProject(target, "CFNetwork.framework", false);
        //     proj.AddFrameworkToProject(target, "Security.framework", false);//微信登录
        //     proj.AddFrameworkToProject(target, "libsqlite3.tbd", false);//微信登录
        //     proj.AddFrameworkToProject(target, "libstdc++.6.0.9.tbd", false);
        //     proj.AddFrameworkToProject(target, "libz.tbd", false);//微信登录
        //     proj.AddBuildProperty(target, "OTHER_LDFLAGS", "-ObjC");//微信登录
        //     proj.AddBuildProperty(target, "OTHER_LDFLAGS", "-all_load");//微信登录
        //     // 書き出し
        //     System.IO.File.WriteAllText(projPath, proj.WriteToString());


        //     //

        //     // 设置签名
        //     //			proj.SetBuildProperty (target, "CODE_SIGN_IDENTITY", "iPhone Distribution: _______________");
        //     //			proj.SetBuildProperty (target, "PROVISIONING_PROFILE", "********-****-****-****-************");

        //     // 保存工程
        //     proj.WriteToFile(projPath);

        //     //修改plist
        //     string plistPath = path + "/Info.plist";
        //     PlistDocument plist = new PlistDocument();
        //     plist.ReadFromString(File.ReadAllText(plistPath));
        //     PlistElementDict rootDict = plist.root;

        //     var arrAqs = rootDict.CreateArray("LSApplicationQueriesSchemes");//微信登录
        //     arrAqs.AddString("weixin");//微信登录
        //     arrAqs.AddString("wechat");//微信登录

        //     var arrUrlTypes = rootDict.CreateArray("CFBundleURLTypes");
        //     {
        //         //微信通知回调
        //         var item0 = arrUrlTypes.AddDict();
        //         item0.SetString("CFBundleURLName", "weixin");
        //         item0.SetString("CFBundleTypeRole", "Editor");
        //         var arrUrlSchemes = item0.CreateArray("CFBundleURLSchemes");
        //         arrUrlSchemes.AddString("wxb0ad5afde0479df0");
        //     }


        //     // 语音所需要的声明,iOS10必须
        //     //rootDict.SetString("NSContactsUsageDescription", "是否允许此游戏使用麦克风?");

        //     // 保存plist
        //     plist.WriteToFile(plistPath);
        //     System.IO.File.WriteAllText(plistPath, plist.WriteToString());
        // }
    }
示例#10
0
        public static void OnPostprocessBuild(BuildTarget target, string projectPath)
        {
            var pbxProjPath = PBXProject.GetPBXProjectPath(projectPath);


            PBXProject proj = new PBXProject();

            proj.ReadFromFile(pbxProjPath);
            string targetGuid = proj.TargetGuidByName("Unity-iPhone");


            RegisterAppLanguages();

            AddFlags(proj, targetGuid);
            AddLibraries(proj, targetGuid);
            AddFrameworks(proj, targetGuid, target);
            AddEmbededFrameworks(proj, targetGuid);
            AddPlistVariables(proj, projectPath, targetGuid);
            ApplyBuildSettings(proj, targetGuid);
            CopyAssetFiles(proj, projectPath, targetGuid);
            AddShellScriptBuildPhase(proj, targetGuid);

            proj.WriteToFile(pbxProjPath);


            var capManager = new ProjectCapabilityManager(pbxProjPath, ISD_Settings.ENTITLEMENTS_FILE_NAME, "Unity-iPhone");

            AddCapabilities(proj, targetGuid, capManager);
            capManager.WriteToFile();



            //Some API simply does not work so on this block we are applying a workaround
            //after Unity deploy scrips has stopped working

            //Addons EmbededFrameworks
            foreach (var framework in ISD_Settings.Instance.EmbededFrameworks)
            {
                string contents    = File.ReadAllText(pbxProjPath);
                string pattern     = "(?<=Embed Frameworks)(?:.*)(\\/\\* " + framework.FileName + "\\ \\*\\/)(?=; };)";
                string oldText     = "/* " + framework.FileName + " */";
                string updatedText = "/* " + framework.FileName + " */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }";
                contents = Regex.Replace(contents, pattern, m => m.Value.Replace(oldText, updatedText));
                File.WriteAllText(pbxProjPath, contents);
            }


            var entitlementsPath = projectPath + "/" + ISD_Settings.ENTITLEMENTS_FILE_NAME;

            if (ISD_Settings.Instance.EntitlementsMode == ISD_EntitlementsGenerationMode.Automatic)
            {
                if (ISD_Settings.Instance.Capability.iCloud.Enabled)
                {
                    if (ISD_Settings.Instance.Capability.iCloud.keyValueStorage && !ISD_Settings.Instance.Capability.iCloud.iCloudDocument)
                    {
                        var entitlements = new PlistDocument();
                        entitlements.ReadFromFile(entitlementsPath);

                        var plistVariable = new PlistElementArray();
                        entitlements.root["com.apple.developer.icloud-container-identifiers"] = plistVariable;

                        entitlements.WriteToFile(entitlementsPath);
                    }
                }
            }
            else
            {
                if (ISD_Settings.Instance.EntitlementsFile != null)
                {
                    var    entitlementsContentPath = SA_AssetDatabase.GetAbsoluteAssetPath(ISD_Settings.Instance.EntitlementsFile);
                    string contents = File.ReadAllText(entitlementsContentPath);
                    File.WriteAllText(entitlementsPath, contents);
                }
                else
                {
                    Debug.LogWarning("ISD: EntitlementsMode set to Manual but no file provided");
                }
            }
        }
        // ReSharper disable once UnusedParameter.Local
        private static void Setup_XCodePlist(string strXCodeProjectPath)
        {
#if UNITY_IOS
            Debug.Log($"{const_strPrefix_ForDebugLog} {nameof(Setup_XCodePlist)} Start - {nameof(strXCodeProjectPath)} : {strXCodeProjectPath}");
            BuildConfig.IOSSetting pIOSSetting = g_pLastConfig.pIOSSetting;

            // Property List(.plist) Default Name
            const string strInfoPlistName = "Info.plist";

            var str_plistPath   = Path.Combine(strXCodeProjectPath, strInfoPlistName);
            var p_plistDocument = new PlistDocument();
            p_plistDocument.ReadFromFile(str_plistPath);



            // 해당 키는 IOS 업로드 시 해당 키는 지원하지 않는다는 에러 발생으로 인해 제거
            const string strExitsOnSuspendKey = "UIApplicationExitsOnSuspend";
            var          arrRootValues        = p_plistDocument.root.values;
            if (arrRootValues.ContainsKey(strExitsOnSuspendKey))
            {
                arrRootValues.Remove(strExitsOnSuspendKey);
            }

            foreach (var pProperty in pIOSSetting.arrAddPlist)
            {
                Debug.Log($"{const_strPrefix_ForDebugLog} Add Property - Key : \"{pProperty.strKey}\" Value : {pProperty.strValue}");

                if (arrRootValues.ContainsKey(pProperty.strKey))
                {
                    arrRootValues[pProperty.strKey] = new PlistElementString(pProperty.strValue);
                }
                else
                {
                    arrRootValues.Add(pProperty.strKey, new PlistElementString(pProperty.strValue));
                }
            }

            foreach (string strRemovePropertyKey in pIOSSetting.arrRemovePlistKey)
            {
                if (arrRootValues.ContainsKey(strRemovePropertyKey))
                {
                    arrRootValues.Remove(strRemovePropertyKey);
                    Debug.Log($"{const_strPrefix_ForDebugLog} Contains & Removed Key.Length : {strRemovePropertyKey}");
                }
            }

            Debug.Log($"{const_strPrefix_ForDebugLog} pIOSSetting.arrHTTPAddress.Length : \"{pIOSSetting.arrHTTPAddress.Length}\"");

            // HTTP 주소는 Plist에 추가해야 접근 가능..
            if (pIOSSetting.arrHTTPAddress.Length != 0)
            {
                PlistElementDict pTransportDict        = Get_Or_Add_PlistDict(arrRootValues, "NSAppTransportSecurity");
                PlistElementDict pExceptionDomainsDict = Get_Or_Add_PlistDict(pTransportDict.values, "NSExceptionDomains");

                foreach (string strAddress in pIOSSetting.arrHTTPAddress)
                {
                    Debug.Log($"{const_strPrefix_ForDebugLog} Add HTTPAddress : \"{strAddress}\"");

                    PlistElementDict pTransportDomain = Get_Or_Add_PlistDict(pExceptionDomainsDict.values, strAddress);
                    const string     strNSAllowInsecureHTTPLoadsKey = "NSExceptionAllowsInsecureHTTPLoads";
                    const string     strNSIncludesSubdomains        = "NSIncludesSubdomains";


                    if (pTransportDomain.values.ContainsKey(strNSAllowInsecureHTTPLoadsKey) == false)
                    {
                        pTransportDomain.values.Add(strNSAllowInsecureHTTPLoadsKey, new PlistElementBoolean(true));
                    }

                    if (pTransportDomain.values.ContainsKey(strNSIncludesSubdomains) == false)
                    {
                        pTransportDomain.values.Add(strNSIncludesSubdomains, new PlistElementBoolean(true));
                    }
                }
            }

            // Apply editing settings to Info.plist
            p_plistDocument.WriteToFile(str_plistPath);
            Debug.Log($"{const_strPrefix_ForDebugLog} {nameof(Setup_XCodePlist)} - WriteToFile {str_plistPath}");
#else
            Debug.Log($"{const_strPrefix_ForDebugLog} {nameof(Setup_XCodePlist)} - Not Define Symbol is Not IOS");
#endif
        }
示例#12
0
        public static void ChangeXcodePlist(BuildTarget buildTarget, string pathToBuiltProject)
        {
            if (buildTarget != BuildTarget.iOS)
            {
                return;
            }

            if (LocalizationManager.Sources.Count <= 0)
            {
                LocalizationManager.UpdateSources();
            }
            var langCodes = LocalizationManager.GetAllLanguagesCode(false);

            if (langCodes.Count <= 0)
            {
                return;
            }

            try
            {
                //----[ Export localized languages to the info.plist ]---------

                string        plistPath = pathToBuiltProject + "/Info.plist";
                PlistDocument plist     = new PlistDocument();
                plist.ReadFromString(File.ReadAllText(plistPath));

                PlistElementDict rootDict = plist.root;

                // Get Language root
                var langArray = rootDict.CreateArray("CFBundleLocalizations");

                // Set the Language Codes
                foreach (var code in langCodes)
                {
                    if (code == null || code.Length < 2)
                    {
                        continue;
                    }
                    langArray.AddString(code);
                }

                rootDict.SetString("CFBundleDevelopmentRegion", langCodes[0]);

                // Write to file
                File.WriteAllText(plistPath, plist.WriteToString());

                //--[ Localize App Name ]----------

                string LocalizationRoot = pathToBuiltProject + "/I2Localization";
                if (!Directory.Exists(LocalizationRoot))
                {
                    Directory.CreateDirectory(LocalizationRoot);
                }

                var    project  = new PBXProject();
                string projPath = PBXProject.GetPBXProjectPath(pathToBuiltProject);
                //if (!projPath.EndsWith("xcodeproj"))
                //projPath = projPath.Substring(0, projPath.LastIndexOfAny("/\\".ToCharArray()));

                project.ReadFromFile(projPath);
                //var targetName = PBXProject.GetUnityTargetName();
                //string projBuild = project.TargetGuidByName( targetName );

                // Set the Language Overrides
                foreach (var code in langCodes)
                {
                    if (code == null || code.Length < 2)
                    {
                        continue;
                    }

                    var LanguageDirRoot = LocalizationRoot + "/" + code + ".lproj";
                    if (!Directory.Exists(LanguageDirRoot))
                    {
                        Directory.CreateDirectory(LanguageDirRoot);
                    }

                    var infoPlistPath = LanguageDirRoot + "/InfoPlist.strings";
                    var InfoPlist     = string.Format("CFBundleDisplayName = \"{0}\";", LocalizationManager.GetAppName(code));
                    File.WriteAllText(infoPlistPath, InfoPlist);

                    var langProjectRoot = "I2Localization/" + code + ".lproj";

                    var stringPaths = LanguageDirRoot + "/Localizable.strings";
                    File.WriteAllText(stringPaths, string.Empty);

                    project.AddLocalization(langProjectRoot + "/Localizable.strings", langProjectRoot + "/Localizable.strings", "I2 Localization");
                    project.AddLocalization(langProjectRoot + "/InfoPlist.strings", langProjectRoot + "/InfoPlist.strings", "I2 Localization");
                }

                project.WriteToFile(projPath);
            }
            catch (System.Exception e)
            {
                Debug.Log(e);
            }
        }
示例#13
0
        private static void PostProcessMacOS(string path)
        {
            var settings = GetBuildSettings();

            if (settings.EnablePostProcessMacOS == false)
            {
                Debug.Log("[HovelHouse.CloudKit] skipping post process build step...");
                return;
            }

            try
            {
                // This step merges the plist thats in the app folder with a partial
                // one you specify
                var appPList     = new PlistDocument();
                var appPListPath = Path.Combine(path, "Contents/info.plist");

                appPList.ReadFromFile(appPListPath);
                PlistElementDict appRoot = appPList.root;

                if (settings.PerformMergePlistsStep)
                {
                    Debug.Log("[HovelHouse.CloudKit] merging plists");

                    var partialPList = new PlistDocument();

                    partialPList.ReadFromFile(settings.PlistPath);

                    PlistElementDict partialProot = partialPList.root;

                    foreach (var prop in partialProot.values)
                    {
                        appRoot[prop.Key] = prop.Value;
                    }
                }

                appPList.WriteToFile(appPListPath);

                var appEntitlements = new PlistDocument();

                if (settings.PerformMergeEntitlementsStep && string.IsNullOrEmpty(settings.EntitlementsPath) == false)
                {
                    appEntitlements.ReadFromFile(settings.EntitlementsPath);
                }

                // Add cloud kit service if it's not in there already
                if (settings.EnableCloudKit)
                {
                    if (!(appEntitlements.root[iCloudServicesEntitlement] is PlistElementArray cloudServices))
                    {
                        cloudServices = appEntitlements.root.CreateArray(iCloudServicesEntitlement);
                    }

                    cloudServices.AddIfMissing("CloudKit");
                }

                var cloudContainers = appEntitlements.root.CreateArray(ContainersEntitlement);
                if (settings.AddDefaultContainers)
                {
                    var defaultContainerName = string.Format("iCloud.{0}", PlayerSettings.applicationIdentifier);
                    cloudContainers.AddIfMissing(defaultContainerName);
                }
                cloudContainers.AddRangeIfMissing(settings.CustomContainers);

                // Normally x-code adds the ApplicationIdentifierEntitlement during signing, but we're not
                // building to an xcode project so we have to do this step manually
                // https://developer.apple.com/documentation/security/keychain_services/keychain_items/sharing_access_to_keychain_items_among_a_collection_of_apps?language=objc

                if (appEntitlements.root.values.ContainsKey(ApplicationIdentifierEntitlement) == false)
                {
                    string teamId = PlayerSettings.iOS.appleDeveloperTeamID;

                    if (string.IsNullOrEmpty(teamId))
                    {
                        throw new BuildFailedException("[HovelHouse] Please set an appled delevelop team ID in the iOS project settings. It is required by MacOS for code signing.");
                    }

                    string appId = PlayerSettings.applicationIdentifier;

                    appEntitlements.root.SetString(ApplicationIdentifierEntitlement, string.Format("{0}.{1}", teamId, appId));
                }

                if (settings.EnableKeyVaueStorage)
                {
                    appEntitlements.root.SetString(KeyValueStoreEntitlement, "$(TeamIdentifierPrefix)$(CFBundleIdentifier)");
                }

                if (settings.EnableCloudKitNotifications)
                {
                    var apsEnvironment = settings.apsEnvironment.ToString().ToLowerInvariant();
                    appEntitlements.root.AddIfMissing(PushNotificationEntitlementKey, apsEnvironment);
                }

                var appEntitlementsPath = Path.Combine(path,
                                                       string.Format("../{0}.entitlements", PlayerSettings.applicationIdentifier.Split('.').Last()));
                appEntitlements.WriteToFile(appEntitlementsPath);

                string scriptPath = Path.GetFullPath("Packages/com.hovelhouse.cloudkit/ShellScripts/resign.sh");

                // null checks
                if (string.IsNullOrEmpty(settings.CodeSigningIdentity))
                {
                    throw new Exception("[HovelHouse CloudKit] Please supply a Code Signing Identity in build settings");
                }

                if (string.IsNullOrEmpty(settings.ProvisioningProfilePath))
                {
                    throw new Exception("[HovelHouse CloudKit] Please supply the path to your provisioning profile in build settings");
                }

                Process proc = new Process();
                proc.StartInfo.CreateNoWindow         = false;
                proc.StartInfo.UseShellExecute        = false;
                proc.StartInfo.RedirectStandardError  = true;
                proc.StartInfo.RedirectStandardOutput = true;
                proc.StartInfo.FileName = scriptPath;

                var args = string.Format("-a \"{0}\" -i \"{1}\" -e \"{2}\" -v \"{3}\"",
                                         path,
                                         settings.CodeSigningIdentity,
                                         appEntitlementsPath,
                                         settings.ProvisioningProfilePath);

                proc.StartInfo.Arguments = args;

                Debug.Log(string.Format("[HovelHouse CloudKit] {0} {1}", scriptPath, args));

                proc.Start();
                var resultMsg = proc.StandardOutput.ReadToEnd();
                var errorMsg  = proc.StandardError.ReadToEnd();

                while (!proc.WaitForExit(10000))
                {
                    ;
                }

                if (proc.ExitCode != 0)
                {
                    Debug.LogError("[HovelHouse CloudKit] CodeSigning Failed");
                    if (errorMsg != null)
                    {
                        throw new BuildFailedException(errorMsg);
                    }
                    else
                    {
                        throw new BuildFailedException(resultMsg);
                    }
                }
                else
                {
                    Debug.Log(resultMsg);
                }
            }
            catch (Exception ex)
            {
                throw new BuildFailedException(ex);
            }
        }
        static void ModifyPlist(string path)
        {
            // Info.plist
            string        plistPath = path + "/Info.plist";
            PlistDocument plist     = new PlistDocument();

            plist.ReadFromString(File.ReadAllText(path: plistPath));

            // ROOT
            PlistElementDict  rootDict = plist.root;
            PlistElementArray urlTypes = rootDict.CreateArray("CFBundleURLTypes");

            // Add URLScheme For Wechat
            PlistElementDict wxUrl = urlTypes.AddDict();

            wxUrl.SetString("CFBundleTypeRole", "Editor");
            wxUrl.SetString("CFBundleURLName", "weixin");
            wxUrl.SetString("CFBundleURLSchemes", val: Config.wechatAppId);
            PlistElementArray wxUrlScheme = wxUrl.CreateArray("CFBundleURLSchemes");

            wxUrlScheme.AddString(val: Config.wechatAppId);

            // Add URLScheme For jiguang
            // 暂时注释 https://community.jiguang.cn/t/topic/33910
//            PlistElementDict jgUrl = urlTypes.AddDict();
//            jgUrl.SetString("CFBundleTypeRole", "Editor");
//            jgUrl.SetString("CFBundleURLName", "jiguang");
//            jgUrl.SetString("CFBundleURLSchemes", val: "jiguang-" + Config.jgAppKey);
//            PlistElementArray jgUrlScheme = jgUrl.CreateArray("CFBundleURLSchemes");
//            jgUrlScheme.AddString(val: "jiguang-" + Config.jgAppKey);

            // Add URLScheme For unityconnect
            PlistElementDict appUrl = urlTypes.AddDict();

            appUrl.SetString("CFBundleTypeRole", "Editor");
            appUrl.SetString("CFBundleURLName", "");
            appUrl.SetString("CFBundleURLSchemes", val: "unityconnect");
            PlistElementArray appUrlScheme = appUrl.CreateArray("CFBundleURLSchemes");

            appUrlScheme.AddString(val: "unityconnect");

            // 白名单 for wechat
            PlistElementArray queriesSchemes = rootDict.CreateArray("LSApplicationQueriesSchemes");

            queriesSchemes.AddString("wechat");
            queriesSchemes.AddString("weixin");
            queriesSchemes.AddString(val: Config.wechatAppId);

            // HTTP 设置
            const string     atsKey  = "NSAppTransportSecurity";
            PlistElementDict dictTmp = rootDict.CreateDict(key: atsKey);

            dictTmp.SetBoolean("NSAllowsArbitraryLoads", true);

            // 出口合规信息
            rootDict.SetBoolean("ITSAppUsesNonExemptEncryption", false);

            rootDict.SetString("NSCameraUsageDescription", "我们需要访问您的相机,以便您正常使用修改头像、发送图片、扫一扫等功能");
            rootDict.SetString("NSPhotoLibraryUsageDescription", "我们需要访问您的相册,以便您正常使用修改头像、发送图片或者视频等功能");
            rootDict.SetString("NSPhotoLibraryAddUsageDescription", "我们需要访问您的相册,以便您正常使用保存图片功能");
//            rootDict.SetString("NSMicrophoneUsageDescription", "需要录制音频,是否允许此App打开麦克风?");

            // remove exit on suspend if it exists.
            string exitsOnSuspendKey = "UIApplicationExitsOnSuspend";

            if (rootDict.values.ContainsKey(exitsOnSuspendKey))
            {
                rootDict.values.Remove(exitsOnSuspendKey);
            }

            // 写入
            File.WriteAllText(plistPath, plist.WriteToString());
        }
示例#15
0
    /// <summary>
    /// 修改InfoPlist
    /// </summary>
    static void EditInfoPlist(string prjPath)
    {
        var           plistPath = Path.Combine(prjPath, "Info.plist");
        PlistDocument plist     = new PlistDocument();

        plist.ReadFromFile(plistPath);

        //Unity 项目常规要做的2项修改
        plist.root.SetBoolean("ITSAppUsesNonExemptEncryption", false);
        string exitsOnSuspendKey = "UIApplicationExitsOnSuspend";

        if (plist.root.values.ContainsKey(exitsOnSuspendKey))
        {
            plist.root.values.Remove(exitsOnSuspendKey);
        }

        //Google id for admob
        plist.root.SetString("GADApplicationIdentifier", "ca-app-pub-9488501426181082/7319780494");
        plist.root.SetBoolean("GADIsAdManagerApp", true);

        //Some channels use the Get Location feature internally
        plist.root.SetString("NSLocationWhenInUseUsageDescription", "The app needs to get your location");
        //Get IDFA permission configuration ,iOS14 support
        plist.root.SetString("NSUserTrackingUsageDescription", "This identifier will be used to deliver personalized ads to you");

        //使用SKAdNetwork跟踪转化:
        var elementArray = plist.root.CreateArray("SKAdNetworkItems");
        //google admob
        var dict = elementArray.AddDict();

        dict.SetString("SKAdNetworkIdentifier", "cstr6suwn9.skadnetwork");
        //Pangle
        dict = elementArray.AddDict();
        dict.SetString("SKAdNetworkIdentifier", "238da6jt44.skadnetwork");
        dict = elementArray.AddDict();
        dict.SetString("SKAdNetworkIdentifier", "22mmun2rn5.skadnetwork");
        //IronSource
        dict = elementArray.AddDict();
        dict.SetString("SKAdNetworkIdentifier", "SU67R6K2V3.skadnetwork");
        //UnityAds
        dict = elementArray.AddDict();
        dict.SetString("SKAdNetworkIdentifier", "4DZT52R2T5.skadnetwork");
        dict = elementArray.AddDict();
        dict.SetString("SKAdNetworkIdentifier", "bvpn9ufa9b.skadnetwork");
        //AdColony
        dict = elementArray.AddDict();
        dict.SetString("SKAdNetworkIdentifier", "4PFYVQ9L8R.skadnetwork");
        dict = elementArray.AddDict();
        dict.SetString("SKAdNetworkIdentifier", "YCLNXRL5PM.skadnetwork");
        dict = elementArray.AddDict();
        dict.SetString("SKAdNetworkIdentifier", "V72QYCH5UU.skadnetwork");
        dict = elementArray.AddDict();
        dict.SetString("SKAdNetworkIdentifier", "TL55SBB4FM.skadnetwork");
        dict = elementArray.AddDict();
        dict.SetString("SKAdNetworkIdentifier", "T38B2KH725.skadnetwork");
        dict = elementArray.AddDict();
        dict.SetString("SKAdNetworkIdentifier", "PRCB7NJMU6.skadnetwork");
        dict = elementArray.AddDict();
        dict.SetString("SKAdNetworkIdentifier", "PPXM28T8AP.skadnetwork");
        dict = elementArray.AddDict();
        dict.SetString("SKAdNetworkIdentifier", "MLMMFZH3R3.skadnetwork");
        dict = elementArray.AddDict();
        dict.SetString("SKAdNetworkIdentifier", "KLF5C3L5U5.skadnetwork");
        dict = elementArray.AddDict();
        dict.SetString("SKAdNetworkIdentifier", "HS6BDUKANM.skadnetwork");
        dict = elementArray.AddDict();
        dict.SetString("SKAdNetworkIdentifier", "C6K4G5QG8M.skadnetwork");
        dict = elementArray.AddDict();
        dict.SetString("SKAdNetworkIdentifier", "9T245VHMPL.skadnetwork");
        dict = elementArray.AddDict();
        dict.SetString("SKAdNetworkIdentifier", "9RD848Q2BZ.skadnetwork");
        dict = elementArray.AddDict();
        dict.SetString("SKAdNetworkIdentifier", "8S468MFL3Y.skadnetwork");
        dict = elementArray.AddDict();
        dict.SetString("SKAdNetworkIdentifier", "7UG5ZH24HU.skadnetwork");
        dict = elementArray.AddDict();
        dict.SetString("SKAdNetworkIdentifier", "4FZDC2EVR5.skadnetwork");
        dict = elementArray.AddDict();
        dict.SetString("SKAdNetworkIdentifier", "4468KM3ULZ.skadnetwork");
        dict = elementArray.AddDict();
        dict.SetString("SKAdNetworkIdentifier", "3RD42EKR43.skadnetwork");
        dict = elementArray.AddDict();
        dict.SetString("SKAdNetworkIdentifier", "2U9PT9HC89.skadnetwork");
        //Mintegral
        dict = elementArray.AddDict();
        dict.SetString("SKAdNetworkIdentifier", "KBD757YWX3.skadnetwork");
        dict = elementArray.AddDict();
        dict.SetString("SKAdNetworkIdentifier", "wg4vff78zm.skadnetwork");
        dict = elementArray.AddDict();
        dict.SetString("SKAdNetworkIdentifier", "737z793b9f.skadnetwork");
        dict = elementArray.AddDict();
        dict.SetString("SKAdNetworkIdentifier", "ydx93a7ass.skadnetwork");
        dict = elementArray.AddDict();
        dict.SetString("SKAdNetworkIdentifier", "prcb7njmu6.skadnetwork");
        dict = elementArray.AddDict();
        dict.SetString("SKAdNetworkIdentifier", "7UG5ZH24HU.skadnetwork");
        dict = elementArray.AddDict();
        dict.SetString("SKAdNetworkIdentifier", "44jx6755aq.skadnetwork");
        dict = elementArray.AddDict();
        dict.SetString("SKAdNetworkIdentifier", "2U9PT9HC89.skadnetwork");
        dict = elementArray.AddDict();
        dict.SetString("SKAdNetworkIdentifier", "W9Q455WK68.skadnetwork");
        dict = elementArray.AddDict();
        dict.SetString("SKAdNetworkIdentifier", "YCLNXRL5PM.skadnetwork");
        dict = elementArray.AddDict();
        dict.SetString("SKAdNetworkIdentifier", "TL55SBB4FM.skadnetwork");
        dict = elementArray.AddDict();
        dict.SetString("SKAdNetworkIdentifier", "8s468mfl3y.skadnetwork");
        dict = elementArray.AddDict();
        dict.SetString("SKAdNetworkIdentifier", "GLQZH8VGBY.skadnetwork");
        dict = elementArray.AddDict();
        dict.SetString("SKAdNetworkIdentifier", "c6k4g5qg8m.skadnetwork");
        dict = elementArray.AddDict();
        dict.SetString("SKAdNetworkIdentifier", "mlmmfzh3r3.skadnetwork");
        dict = elementArray.AddDict();
        dict.SetString("SKAdNetworkIdentifier", "4PFYVQ9L8R.skadnetwork");
        dict = elementArray.AddDict();
        dict.SetString("SKAdNetworkIdentifier", "av6w8kgt66.skadnetwork");
        dict = elementArray.AddDict();
        dict.SetString("SKAdNetworkIdentifier", "6xzpu9s2p8.skadnetwork");
        dict = elementArray.AddDict();
        dict.SetString("SKAdNetworkIdentifier", "hs6bdukanm.skadnetwork");
        //Sigmob
        dict = elementArray.AddDict();
        dict.SetString("SKAdNetworkIdentifier", "58922NB4GD.skadnetwork");
        //Maio
        dict = elementArray.AddDict();
        dict.SetString("SKAdNetworkIdentifier", "V4NXQHLYQP.skadnetwork");
        //Vungle
        dict = elementArray.AddDict();
        dict.SetString("SKAdNetworkIdentifier", "GTA9LK7P23.skadnetwork");
        //Facebook
        dict = elementArray.AddDict();
        dict.SetString("SKAdNetworkIdentifier", "v9wttpbfk9.skadnetwork");
        dict = elementArray.AddDict();
        dict.SetString("SKAdNetworkIdentifier", "n38lu8286q.skadnetwork");

        plist.WriteToFile(plistPath);
    }
示例#16
0
    public static void ChangeXcodePlist(BuildTarget buildTarget, string pathToBuiltProject)
    {
        if (buildTarget == BuildTarget.iOS)
        {
            Debug.Log("iOS post build");
            string        plistPath = pathToBuiltProject + "/Info.plist";
            PlistDocument plist     = new PlistDocument();
            plist.ReadFromFile(plistPath);

            PlistElementDict rootDict = plist.root;

            // allow the app to open JSON/N-Space files
            // https://developer.apple.com/documentation/uikit/view_controllers/adding_a_document_browser_to_your_app/setting_up_a_document_browser_app

            // TODO? https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/iPhoneOSKeys.html#//apple_ref/doc/uid/TP40009252-SW37
            //rootDict.SetBoolean("UISupportsDocumentBrowser", true);

            rootDict.SetBoolean("LSSupportsOpeningDocumentsInPlace", false);

            var documentTypesArray = rootDict.CreateArray("CFBundleDocumentTypes");

            var nspaceDocTypeDict = documentTypesArray.AddDict();
            // reference: https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html#//apple_ref/doc/uid/TP40009249-101685-TPXREF107
            nspaceDocTypeDict.CreateArray("CFBundleTypeIconFiles"); // empty
            nspaceDocTypeDict.SetString("CFBundleTypeName", "N-Space World");
            nspaceDocTypeDict.SetString("LSHandlerRank", "Owner");  // this app both creates and opens N-Space files
            var nspaceContentTypesArray = nspaceDocTypeDict.CreateArray("LSItemContentTypes");
            nspaceContentTypesArray.AddString("com.vantjac.nspace");

            // built in types
            AddDocumentType(documentTypesArray, "JSON file", "public.json");
            AddDocumentType(documentTypesArray, "MP3 audio", "public.mp3");
            AddDocumentType(documentTypesArray, "Waveform audio", "com.microsoft.waveform-audio");
            AddDocumentType(documentTypesArray, "AIFF-C audio", "public.aifc-audio");
            AddDocumentType(documentTypesArray, "AIFF audio", "public.aiff-audio");
            // not built in (borrowed from VLC)
            AddDocumentType(documentTypesArray, "Ogg Vorbis Audio File", "org.videolan.ogg-audio");
            AddDocumentType(documentTypesArray, "Fasttracker 2 Extended Module", "org.videolan.xm");
            AddDocumentType(documentTypesArray, "Impulse Tracker Module", "org.videolan.it");

            // declare the N-Space file type
            // put it in "Exported" types because N-Space owns this file format
            var exportedTypesArray    = rootDict.CreateArray("UTExportedTypeDeclarations");
            var nspaceDeclarationDict = exportedTypesArray.AddDict();
            nspaceDeclarationDict.SetString("UTTypeIdentifier", "com.vantjac.nspace");
            nspaceDeclarationDict.SetString("UTTypeDescription", "N-Space World");
            var conformsToArray = nspaceDeclarationDict.CreateArray("UTTypeConformsTo");
            conformsToArray.AddString("public.data");
            var tagSpecificationsDict = nspaceDeclarationDict.CreateDict("UTTypeTagSpecification");
            tagSpecificationsDict.SetString("com.apple.ostype", "NSPA");
            tagSpecificationsDict.SetString("public.filename-extension", "nspace");
            tagSpecificationsDict.SetString("public.mime-type", "application/vnd.vantjac.nspace");

            // these are "Imported" types, which are types we declare but don't own
            // other apps that do own the types (exported) will override these
            var importedTypesArray = rootDict.CreateArray("UTImportedTypeDeclarations");
            AddImportedType(importedTypesArray, "Ogg Vorbis Audio File",
                            "org.videolan.ogg-audio", "public.audio", new string[] { "ogg", "oga" },
                            new string[] { "audio/ogg", "application/ogg", "application/x-ogg", "audio/vorbis" });
            AddImportedType(importedTypesArray,
                            "Fasttracker 2 Extended Module", "org.videolan.xm", "public.audio",
                            new string[] { "xm" }, new string[] { "audio/xm" });
            AddImportedType(importedTypesArray,
                            "Impulse Tracker Module", "org.videolan.it", "public.audio",
                            new string[] { "it" }, new string[] { "audio/it" });

            plist.WriteToFile(plistPath);
        }
    }
示例#17
0
        public bool InitWithFile(string plistFile)
        {
            bool bRet;
            m_sPlistFile = CCFileUtils.FullPathFromRelativePath(plistFile);

            //var content = CCApplication.SharedApplication.content.Load<CCContent>(m_sPlistFile);
            //PlistDocument dict = PlistDocument.Create(content.Content);

            PlistDocument doc = null;
            try
            {
                doc = CCApplication.SharedApplication.Content.Load<PlistDocument>(m_sPlistFile);
            }
            catch (Exception)
            {
                string xml = Cocos2D.Framework.CCContent.LoadContentFile(m_sPlistFile);
                if (xml != null)
                {
                    doc = new PlistDocument(xml);
                }
            }
            if (doc == null)
            {
                throw (new Microsoft.Xna.Framework.Content.ContentLoadException("Failed to load the particle definition file from " + m_sPlistFile));
            }
            Debug.Assert(doc != null, "Particles: file not found");
            Debug.Assert(doc.Root != null, "Particles: file not found");

            bRet = InitWithDictionary(doc.Root.AsDictionary);

            return bRet;
        }
 public static bool ContainsKey(this PlistDocument plist, string key)
 {
     return(plist.root.values.ContainsKey(key));
 }
示例#19
0
        static void ChangePlist(string pathToBuildProject)
        {
            string        path = string.Format("{0}/Info.plist", pathToBuildProject);
            PlistDocument doc  = new PlistDocument();

            doc.ReadFromString(File.ReadAllText(path));
            PlistElementDict root = doc.root;

            root.SetBoolean("IS_CHINA_MAINLAND", ConfigDataHelper.ChinaMainland);
            root.SetBoolean("IS_RELEASE", ConfigDataHelper.isRelease);

            // 对iOS9的影响
            {
                PlistElementDict security = root.CreateDict("NSAppTransportSecurity");
                security.SetBoolean("NSAllowsArbitraryLoads", true);
            }

            // 合规证明
            {
                root.SetBoolean("ITSAppUsesNonExemptEncryption", false);
            }

            // GameCenter
            {
                PlistElementArray capabilities = root.CreateArray("UIRequiredDeviceCapabilities");
                capabilities.AddString("armv7");
                capabilities.AddString("gamekit");
            }

            // 添加Scheme白名单
            {
                PlistElementArray schemes = root.CreateArray("LSApplicationQueriesSchemes");
                schemes.AddString("fbapi");
                schemes.AddString("fbauth2");
                schemes.AddString("fb-messenger-api");
            }

            // fb
            {
                string idFacebook = "000"; //ConfigDataHelper.FacebookAppID;

                root.SetString("FacebookAppID", idFacebook);
                root.SetString("FacebookDisplayName", PlayerSettings.productName);

                PlistElementArray types = root.CreateArray("CFBundleURLTypes");

                PlistElementDict dict = types.AddDict();
                dict.SetString("CFBundleTypeRole", "Editor");

                PlistElementArray schemes = dict.CreateArray("CFBundleURLSchemes");
                schemes.AddString("fb" + idFacebook);
            }

            // 权限
            {
                root.SetString("NSPhotoLibraryUsageDescription", "使用相册");
                root.SetString("NSCameraUsageDescription", "使用相机");
            }

            File.WriteAllText(path, doc.WriteToString());
        }
示例#20
0
    public static void OnPostProcessBuild(BuildTarget target, string path)
    {
        string     projectPath = PBXProject.GetPBXProjectPath(path);
        PBXProject project     = new PBXProject();

        project.ReadFromString(File.ReadAllText(projectPath));
        string targetName = PBXProject.GetUnityTargetName();
        string targetGUID = project.TargetGuidByName(targetName);

        // UserNotifications.framework is required by libOneSignal.a
        project.AddFrameworkToProject(targetGUID, "UserNotifications.framework", false);

        var extensionTargetName       = "OneSignalNotificationServiceExtension";
        var pathToNotificationService = path + "/" + extensionTargetName;

        Directory.CreateDirectory(pathToNotificationService);

        var notificationServicePlistPath = pathToNotificationService + "/Info.plist";

        PlistDocument notificationServicePlist = new PlistDocument();

        notificationServicePlist.ReadFromFile("Assets/OneSignal/Platforms/iOS/Info.plist");
        notificationServicePlist.root.SetString("CFBundleShortVersionString", PlayerSettings.bundleVersion);
        notificationServicePlist.root.SetString("CFBundleVersion", PlayerSettings.iOS.buildNumber.ToString());

        var notificationServiceTarget = PBXProjectExtensions.AddAppExtension(project, targetGUID, extensionTargetName, PlayerSettings.GetApplicationIdentifier(BuildTargetGroup.iOS) + "." + extensionTargetName, notificationServicePlistPath);

        var sourceDestination = extensionTargetName + "/NotificationService";

        project.AddFileToBuild(notificationServiceTarget, project.AddFile(sourceDestination + ".h", sourceDestination + ".h", PBXSourceTree.Source));
        project.AddFileToBuild(notificationServiceTarget, project.AddFile(sourceDestination + ".m", sourceDestination + ".m", PBXSourceTree.Source));

        var frameworks = new string[] { "NotificationCenter.framework", "UserNotifications.framework", "UIKit.framework", "SystemConfiguration.framework" };

        foreach (string framework in frameworks)
        {
            project.AddFrameworkToProject(notificationServiceTarget, framework, true);
        }

        //makes it so that the extension target is Universal (not just iPhone) and has an iOS 10 deployment target
        project.SetBuildProperty(notificationServiceTarget, "TARGETED_DEVICE_FAMILY", "1,2");
        project.SetBuildProperty(notificationServiceTarget, "IPHONEOS_DEPLOYMENT_TARGET", "10.0");

        project.SetBuildProperty(notificationServiceTarget, "ARCHS", "$(ARCHS_STANDARD)");
        project.SetBuildProperty(notificationServiceTarget, "DEVELOPMENT_TEAM", PlayerSettings.iOS.appleDeveloperTeamID);

        notificationServicePlist.WriteToFile(notificationServicePlistPath);

        FileUtil.CopyFileOrDirectory("Assets/OneSignal/Platforms/iOS/NotificationService.h", path + "/" + sourceDestination + ".h");
        FileUtil.CopyFileOrDirectory("Assets/OneSignal/Platforms/iOS/NotificationService.m", path + "/" + sourceDestination + ".m");

        project.WriteToFile(projectPath);

        //add libOneSignal.a to the OneSignalNotificationServiceExtension target
        string contents = File.ReadAllText(projectPath);

        //this method only modifies the PBXProject string passed in (contents).
        //after this method finishes, we must write the contents string to disk
        InsertStaticFrameworkIntoTargetBuildPhaseFrameworks("libOneSignal", "CD84C25F20742FAB0035D524", notificationServiceTarget, ref contents, project);
        File.WriteAllText(projectPath, contents);

        // enable the Notifications capability in the main app target
        project.ReadFromString(contents);
        var entitlementPath = path + "/" + targetName + "/" + targetName + ".entitlements";

        PlistDocument entitlements = new PlistDocument();

        entitlements.root.SetString("aps-environment", "development");
        entitlements.WriteToFile(entitlementPath);

        // Copy the entitlement file to the xcode project
        var entitlementFileName = Path.GetFileName(entitlementPath);
        var unityTarget         = PBXProject.GetUnityTargetName();
        var relativeDestination = unityTarget + "/" + entitlementFileName;

        // Add the pbx configs to include the entitlements files on the project
        project.AddFile(relativeDestination, entitlementFileName);
        project.AddBuildProperty(targetGUID, "CODE_SIGN_ENTITLEMENTS", relativeDestination);

        // Add push notifications as a capability on the target
        project.AddBuildProperty(targetGUID, "SystemCapabilities", "{com.apple.Push = {enabled = 1;};}");
        File.WriteAllText(projectPath, project.WriteToString());
    }
    public static void OnPostprocessBuild(BuildTarget buildTarget, string pathToBuiltProject)
    {
        //BuildTarget需为iOS
        if (buildTarget != BuildTarget.iOS)
        {
            return;
        }

        #region 配置

        //初始化
        string     projectPath = pathToBuiltProject + "/Unity-iPhone.xcodeproj/project.pbxproj";
        PBXProject pbxProject  = new PBXProject();
        pbxProject.ReadFromFile(projectPath);
        string targetGuid = pbxProject.TargetGuidByName("Unity-iPhone");

        //添加flag
        pbxProject.AddBuildProperty(targetGuid, "OTHER_LDFLAGS", "-ObjC"); //for bugly
        pbxProject.AddBuildProperty(targetGuid, "OTHER_LDFLAGS", "-lz");   //for IFlyMSC
        //关闭Bitcode
        pbxProject.SetBuildProperty(targetGuid, "ENABLE_BITCODE", "NO");   //for IFlyMSC,normal

        //Windows下自动导出的部分斜杠不对,重新设置一次
        pbxProject.SetBuildProperty(targetGuid, "FRAMEWORK_SEARCH_PATHS", "$(inherited)");
        pbxProject.AddBuildProperty(targetGuid, "FRAMEWORK_SEARCH_PATHS", "$(PROJECT_DIR)/Frameworks/Plugins/Bugly/iOS");   //for bugly
        pbxProject.AddBuildProperty(targetGuid, "FRAMEWORK_SEARCH_PATHS", "$(PROJECT_DIR)/Frameworks/Plugins/IFlyMSC/iOS"); //for IFlyMSC

        //Windows下自动导出的部分斜杠不对,重新设置一次
        pbxProject.SetBuildProperty(targetGuid, "LIBRARY_SEARCH_PATHS", "$(inherited)");
        pbxProject.AddBuildProperty(targetGuid, "LIBRARY_SEARCH_PATHS", "$(SRCROOT)");
        pbxProject.AddBuildProperty(targetGuid, "LIBRARY_SEARCH_PATHS", "$(SRCROOT)/Libraries");
        pbxProject.AddBuildProperty(targetGuid, "LIBRARY_SEARCH_PATHS", "$(SRCROOT)/Libraries/Plugins/Bugly/iOS");   //for bugly
        pbxProject.AddBuildProperty(targetGuid, "LIBRARY_SEARCH_PATHS", "$(SRCROOT)/Libraries/Plugins/IFlyMSC/iOS"); //for IFlyMSC

        //添加framwrok
        pbxProject.AddFrameworkToProject(targetGuid, "Security.framework", false);            //for bugly,idfa
        pbxProject.AddFrameworkToProject(targetGuid, "SystemConfiguration.framework", false); //for bugly,IFlyMSC
        pbxProject.AddFrameworkToProject(targetGuid, "JavaScriptCore.framework", true);       //for bugly
        pbxProject.AddFrameworkToProject(targetGuid, "AdSupport.framework", false);           //for idfa

        pbxProject.AddFrameworkToProject(targetGuid, "AVFoundation.framework", false);        //for IFlyMSC
        pbxProject.AddFrameworkToProject(targetGuid, "Foundation.framework", false);          //for IFlyMSC
        pbxProject.AddFrameworkToProject(targetGuid, "CoreTelephony.framework", false);       //for IFlyMSC
        pbxProject.AddFrameworkToProject(targetGuid, "AudioToolbox.framework", false);        //for IFlyMSC
        //pbxProject.AddFrameworkToProject(targetGuid, "UIKit.framework", false);//for IFlyMSC
        //pbxProject.AddFrameworkToProject(targetGuid, "CoreLocation.framework", false);//for IFlyMSC
        pbxProject.AddFrameworkToProject(targetGuid, "Contacts.framework", false);    //for IFlyMSC
        pbxProject.AddFrameworkToProject(targetGuid, "AddressBook.framework", false); //for IFlyMSC
        //pbxProject.AddFrameworkToProject(targetGuid, "QuartzCore.framework", false);//for IFlyMSC
        //pbxProject.AddFrameworkToProject(targetGuid, "CoreGraphics.framework", false);//for IFlyMSC

        //添加lib
        AddLibToProject(pbxProject, targetGuid, "libc++.tbd"); //for bugly
        AddLibToProject(pbxProject, targetGuid, "libz.tbd");   //for bugly,IFlyMSC
        //AddLibToProject(pbxProject, targetGuid, "libicucore.tbd");//for IFlyMSC

        //应用修改
        File.WriteAllText(projectPath, pbxProject.WriteToString());

        #endregion 配置

        #region 修改Info.plist

        // 修改Info.plist文件
        var plistPath = Path.Combine(pathToBuiltProject, "Info.plist");
        var plist     = new PlistDocument();
        plist.ReadFromFile(plistPath);
        plist.root.SetString("NSMicrophoneUsageDescription", "Voice Talk Need Microphone");//for IFlyMSC
        //plist.root.SetString("NSLocationUsageDescription", "Voice Talk Need Location");//for IFlyMSC
        //plist.root.SetString("NSLocationAlwaysUsageDescription", "Voice Talk Need Location");//for IFlyMSC
        //plist.root.SetString("NSContactsUsageDescription", "Voice Talk Need Contacts");//for IFlyMSC
        // 应用修改
        plist.WriteToFile(plistPath);

        #endregion 修改Info.plist
    }
    /*
     * [PostProcessBuildAttribute(1)]
     * public static void OnPostprocessBuild(BuildTarget target, string pathToBuiltProject)
     * {
     *      if(target==BuildTarget.StandaloneOSXUniversal || target==BuildTarget.StandaloneOSXIntel || target==BuildTarget.StandaloneOSXIntel64){
     *              Build(pathToBuiltProject);
     *      }
     * }
     */

    public static void Build(string applicationPath)
    {
        string fileName             = Path.GetFileName(applicationPath);
        string applicationDirectory = Path.GetDirectoryName(applicationPath);

        // load build settings
        MacAppBuildSettings settings = AssetDatabase.LoadAssetAtPath <MacAppBuildSettings>(kSettingsPath);

        if (settings == null)
        {
            settings = ScriptableObject.CreateInstance <MacAppBuildSettings>();
            AssetDatabase.CreateAsset(settings, kSettingsPath);
            AssetDatabase.SaveAssets();
            AssetDatabase.Refresh();
        }

        // copy player icons
        if (!string.IsNullOrEmpty(settings.playerIconsPath))
        {
            File.Copy(settings.playerIconsPath, Path.Combine(applicationPath, "Contents/Resources/PlayerIcon.icns"), true);
        }

        // update info.plist
        string        infoPlistPath = Path.Combine(applicationPath, "Contents/Info.plist");
        PlistDocument info          = new PlistDocument();

        info.ReadFromFile(infoPlistPath);

        PlistElementDict root = info.root;

        root.SetString("CFBundleSignature", settings.bundleIdentifier);
        root.SetString("CFBundleIdentifier", settings.bundleIdentifier);
        root.SetString("CFBundleGetInfoString", settings.applicationDescription);
        root.SetString("LSApplicationCategoryType", settings.applicationCategory);
        root.SetString("CFBundleShortVersionString", PlayerSettings.bundleVersion);
        root.SetString("CFBundleVersion", PlayerSettings.bundleVersion);

        info.WriteToFile(infoPlistPath);

        // copy entitlements
        string entitlementsName = string.Concat(PlayerSettings.productName, ".entitlements");

        if (!string.IsNullOrEmpty(settings.entitlementsPath))
        {
            File.Copy(settings.entitlementsPath, Path.Combine(applicationDirectory, entitlementsName), true);
        }
        else
        {
            throw new UnityException("Entitlements file required");
        }

        // run terminal commands
        ProcessStartInfo startInfo = new ProcessStartInfo("/bin/bash");

        startInfo.WorkingDirectory       = applicationDirectory;
        startInfo.UseShellExecute        = false;
        startInfo.RedirectStandardInput  = true;
        startInfo.RedirectStandardOutput = true;

        Process process = new Process();

        process.StartInfo = startInfo;
        process.Start();

        process.StandardInput.WriteLine(string.Format("chmod -R a+xr {0}", fileName));
        process.StandardInput.WriteLine(string.Format("codesign --force --sign '{2}' --entitlements {0} {1} --deep", entitlementsName, fileName, settings.provisioningProfileApplication));
        process.StandardInput.WriteLine(string.Format("productbuild --component {0} /Applications --sign '{2}' {1}.pkg", fileName, PlayerSettings.productName, settings.provisioningProfileInstaller));

        process.StandardInput.WriteLine("exit");
        process.StandardInput.Flush();

        UnityEngine.Debug.Log(process.StandardOutput.ReadToEnd());

        process.WaitForExit();
    }
    public static void OnPostprocessBuild(BuildTarget buildTarget, string path)
    {
        if (buildTarget != BuildTarget.iOS)
        {
            Debug.Log("这不是IOS平台,不执行操作");
            return;
        }

        string     projPath = PBXProject.GetPBXProjectPath(path);
        PBXProject proj     = new PBXProject();

        proj.ReadFromString(File.ReadAllText(projPath));
        string target = proj.TargetGuidByName("Unity-iPhone");

        //广告依赖库
        List <string> frameworks = new List <string>();

        frameworks.Add("AppcoachsSDK.framework");
        frameworks.Add("GoogleMobileAds.framework");
        frameworks.Add("InMobiSDK.framework");
        frameworks.Add("MVSDK.framework");
        frameworks.Add("MVSDKAppWall.framework");
        frameworks.Add("MVSDKInterstitial.framework");
        frameworks.Add("MVSDKOfferWall.framework");
        frameworks.Add("MVSDKReward.framework");
        frameworks.Add("UnityAds.framework");
        frameworks.Add("VungleSDK.framework");

        //添加依赖库到工程中
        foreach (string framework in frameworks)
        {
            CopyAndReplaceDirectory("Assets/ADFlyHiSDK/Plugins/iOS/frameworks/" + framework, Path.Combine(path, "ADFlyHiSDK/Plugins/iOS/frameworks/" + framework));

            string fileGuid = proj.FindFileGuidByProjectPath("Frameworks/ADFlyHiSDK/Plugins/iOS/frameworks/" + framework);
            proj.RemoveFileFromBuild(target, fileGuid);
            proj.RemoveFile(fileGuid);

            string name = proj.AddFile("ADFlyHiSDK/Plugins/iOS/frameworks/" + framework, "ADFlyHiSDK/Plugins/iOS/frameworks/" + framework, PBXSourceTree.Source);
            proj.AddFileToBuild(target, name);
        }

        DirectoryInfo di = new DirectoryInfo(Path.Combine(path, "Frameworks/ADFlyHiSDK/"));

        di.Delete(true);

        List <string> bundles = new List <string>();

        bundles.Add("appcoachsSDK.bundle");
        bundles.Add("ChanceAdRes.bundle");

        foreach (string bundle in bundles)
        {
            CopyAndReplaceDirectory("Assets/ADFlyHiSDK/Plugins/iOS/resources/" + bundle, Path.Combine(path, "ADFlyHiSDK/Plugins/iOS/frameworks/" + bundle));
            string name = proj.AddFile("ADFlyHiSDK/Plugins/iOS/frameworks/" + bundle, "ADFlyHiSDK/Plugins/iOS/frameworks/" + bundle, PBXSourceTree.Source);
            proj.AddFileToBuild(target, name);
        }

        //tbd依赖包
        List <string> tbds = new List <string>();

        tbds.Add("libsqlite3.tbd");
        tbds.Add("libz.tbd");
        tbds.Add("libz.1.2.5.tbd");
        tbds.Add("libc++.tbd");
        tbds.Add("libxml2.tbd");

        //添加tbd依赖包
        foreach (string tbd in tbds)
        {
            string name = proj.AddFile("usr/lib/" + tbd, "Frameworks/" + tbd, PBXSourceTree.Sdk);
            proj.AddFileToBuild(target, name);
        }

        Debug.Log("添加其他资源");
        File.Copy("Assets/ADFlyHiSDK/Plugins/iOS/resources/[email protected]", Path.Combine(path, "ADFlyHiSDK/Plugins/iOS/frameworks/[email protected]"));
        proj.AddFile("ADFlyHiSDK/Plugins/iOS/frameworks/[email protected]", "ADFlyHiSDK/Plugins/iOS/frameworks/[email protected]", PBXSourceTree.Source);

        File.Copy("Assets/ADFlyHiSDK/Plugins/iOS/resources/[email protected]", Path.Combine(path, "ADFlyHiSDK/Plugins/iOS/frameworks/[email protected]"));
        proj.AddFile("ADFlyHiSDK/Plugins/iOS/frameworks/[email protected]", "ADFlyHiSDK/Plugins/iOS/frameworks/[email protected]", PBXSourceTree.Source);

        //设置buildsetting
        Debug.Log("设置buildsetting");
        proj.SetBuildProperty(target, "OTHER_LDFLAGS", "-ObjC");
        proj.SetBuildProperty(target, "ENABLE_BITCODE", "NO");
        proj.SetBuildProperty(target, "FRAMEWORK_SEARCH_PATHS", "$(inherited)");
        proj.AddBuildProperty(target, "FRAMEWORK_SEARCH_PATHS", "$(PROJECT_DIR)/ADFlyHiSDK/Plugins/iOS/frameworks/");

        proj.WriteToFile(projPath);

        //修改Info.plist
        Debug.Log("修改info.plist");
        string        plistPath = path + "/Info.plist";
        PlistDocument plist     = new PlistDocument();

        plist.ReadFromString(File.ReadAllText(plistPath));
        PlistElementDict rootDic = plist.root.AsDict();

        rootDic.CreateDict("NSAppTransportSecurity").SetBoolean("NSAllowsArbitraryLoads", true);
        rootDic.SetBoolean("UIStatusBarHidden", true);
        rootDic.SetBoolean("UIViewControllerBasedStatusBarAppearance", false);
        rootDic.SetString("NSLocationWhenInUseUsageDescription", "");

        plist.WriteToFile(plistPath);
    }
    public static void AddMegacoolURLScheme(string pathToBuildProject, string customScheme)
    {
        string        plistPath = pathToBuildProject + "/Info.plist";
        PlistDocument plist     = new PlistDocument();

        plist.ReadFromString(File.ReadAllText(plistPath));


        // Get root
        PlistElementDict  rootDict        = plist.root;
        PlistElementArray urlTypesArray   = null;
        PlistElementDict  urlTypesItems   = null;
        PlistElementArray urlSchemesArray = null;

        if (!rootDict.values.ContainsKey("CFBundleURLTypes"))
        {
            urlTypesArray = rootDict.CreateArray("CFBundleURLTypes");
        }
        else
        {
            urlTypesArray = rootDict.values["CFBundleURLTypes"].AsArray();

            if (urlTypesArray == null)
            {
                urlTypesArray = rootDict.CreateArray("CFBundleURLTypes");
            }
        }

        if (urlTypesArray.values.Count == 0)
        {
            urlTypesItems = urlTypesArray.AddDict();
        }
        else
        {
            urlTypesItems = urlTypesArray.values[0].AsDict();

            if (urlTypesItems == null)
            {
                urlTypesItems = urlTypesArray.AddDict();
            }
        }

        if (!urlTypesItems.values.ContainsKey("CFBundleURLSchemes"))
        {
            urlSchemesArray = urlTypesItems.CreateArray("CFBundleURLSchemes");
        }
        else
        {
            urlSchemesArray = urlTypesItems.values["CFBundleURLSchemes"].AsArray();

            if (urlSchemesArray == null)
            {
                urlSchemesArray = urlTypesItems.CreateArray("CFBundleURLSchemes");
            }
        }

        bool megacoolURLSchemeExists = false;

        foreach (PlistElement elem in urlSchemesArray.values)
        {
            if (elem.AsString() != null && elem.AsString().Equals(customScheme))
            {
                megacoolURLSchemeExists = true;
                break;
            }
        }

        if (!megacoolURLSchemeExists)
        {
            urlSchemesArray.AddString(customScheme);
        }

        // Write to file
        File.WriteAllText(plistPath, plist.WriteToString());
    }
示例#25
0
//        private static void EnableConsentFlowIfNeeded(PlistDocument plist)
//        {
//            // Check if consent flow is enabled. No need to update info.plist if consent flow is disabled.
//            var consentFlowEnabled = AppLovinSettings.Instance.ConsentFlowEnabled;
//            if (!consentFlowEnabled) return;
//
//            var userTrackingUsageDescription = AppLovinSettings.Instance.UserTrackingUsageDescription;
//            var termsOfServiceUrl = AppLovinSettings.Instance.ConsentFlowTermsOfServiceUrl;
//            var privacyPolicyUrl = AppLovinSettings.Instance.ConsentFlowPrivacyPolicyUrl;
//            if (string.IsNullOrEmpty(userTrackingUsageDescription) || string.IsNullOrEmpty(termsOfServiceUrl) || string.IsNullOrEmpty(privacyPolicyUrl))
//            {
//                AppLovinIntegrationManager.ShowBuildFailureDialog("You cannot use the AppLovin SDK's consent flow without defining a Terms of Service URL, a Privacy Policy URL and the `User Tracking Usage Description` in the AppLovin Integration Manager. \n\n" +
//                                                                  "All 3 values must be included to enable the SDK's consent flow.");
//
//                // No need to update the info.plist here. Default consent flow state will be determined on the SDK side.
//                return;
//            }
//
//            var consentFlowInfoRoot = plist.root.CreateDict("AppLovinConsentFlowInfo");
//            consentFlowInfoRoot.SetBoolean("AppLovinConsentFlowEnabled", consentFlowEnabled);
//            consentFlowInfoRoot.SetString("AppLovinConsentFlowTermsOfService", termsOfServiceUrl);
//            consentFlowInfoRoot.SetString("AppLovinConsentFlowPrivacyPolicy", privacyPolicyUrl);
//
//            plist.root.SetString("NSUserTrackingUsageDescription", userTrackingUsageDescription);
//        }

        private static void AddSkAdNetworksInfoIfNeeded(PlistDocument plist)
        {
            var skAdNetworkData = GetSkAdNetworkData();
            var skAdNetworkIds  = skAdNetworkData.SkAdNetworkIds;

            // Check if we have a valid list of SKAdNetworkIds that need to be added.
            if (skAdNetworkIds == null || skAdNetworkIds.Length < 1)
            {
                return;
            }

            //
            // Add the SKAdNetworkItems to the plist. It should look like following:
            //
            //    <key>SKAdNetworkItems</key>
            //    <array>
            //        <dict>
            //            <key>SKAdNetworkIdentifier</key>
            //            <string>ABC123XYZ.skadnetwork</string>
            //        </dict>
            //        <dict>
            //            <key>SKAdNetworkIdentifier</key>
            //            <string>123QWE456.skadnetwork</string>
            //        </dict>
            //        <dict>
            //            <key>SKAdNetworkIdentifier</key>
            //            <string>987XYZ123.skadnetwork</string>
            //        </dict>
            //    </array>
            //
            PlistElement skAdNetworkItems;

            plist.root.values.TryGetValue("SKAdNetworkItems", out skAdNetworkItems);
            var existingSkAdNetworkIds = new HashSet <string>();

            // Check if SKAdNetworkItems array is already in the Plist document and collect all the IDs that are already present.
            if (skAdNetworkItems != null && skAdNetworkItems.GetType() == typeof(PlistElementArray))
            {
                var plistElementDictionaries = skAdNetworkItems.AsArray().values.Where(plistElement => plistElement.GetType() == typeof(PlistElementDict));
                foreach (var plistElement in plistElementDictionaries)
                {
                    PlistElement existingId;
                    plistElement.AsDict().values.TryGetValue("SKAdNetworkIdentifier", out existingId);
                    if (existingId == null || existingId.GetType() != typeof(PlistElementString) || string.IsNullOrEmpty(existingId.AsString()))
                    {
                        continue;
                    }

                    existingSkAdNetworkIds.Add(existingId.AsString());
                }
            }
            // Else, create an array of SKAdNetworkItems into which we will add our IDs.
            else
            {
                skAdNetworkItems = plist.root.CreateArray("SKAdNetworkItems");
            }

            foreach (var skAdNetworkId in skAdNetworkIds)
            {
                // Skip adding IDs that are already in the array.
                if (existingSkAdNetworkIds.Contains(skAdNetworkId))
                {
                    continue;
                }

                var skAdNetworkItemDict = skAdNetworkItems.AsArray().AddDict();
                skAdNetworkItemDict.SetString("SKAdNetworkIdentifier", skAdNetworkId);
            }
        }
示例#26
0
        private static void ProcessPlist(string path)
        {
            string        plistPath = path + "/Info.plist";
            PlistDocument plist     = new PlistDocument();

            plist.ReadFromString(File.ReadAllText(plistPath));
            PlistElementDict rootDict = plist.root;

            //PlayerSettings.bundleIdentifier
            rootDict.SetString("CFBundleName", "${PRODUCT_NAME}");
            rootDict.SetString("CFBundleDisplayName", "${PRODUCT_NAME}");
            rootDict.SetString("CFBundleIdentifier", "$(PRODUCT_BUNDLE_IDENTIFIER)");
            rootDict.SetString("CFBundleDevelopmentRegion", "China");
            rootDict.SetString("CFBundleInfoDictionaryVersion", "6.0");
            rootDict.SetString("CFBundleShortVersionString", "1.0.0");
            rootDict.SetString("CFBundleVersion", "1.0.0");

            //NSAppTransportSecurity
            var transportSecurity = rootDict.CreateDict("NSAppTransportSecurity");

            transportSecurity.SetBoolean("NSAllowsArbitraryLoads", true);

            //UISupportedInterfaceOrientations
            var orientation = rootDict.CreateArray("UISupportedInterfaceOrientations");

            orientation.AddString("UIInterfaceOrientationLandscapeRight");
            orientation.AddString("UIInterfaceOrientationLandscapeLeft");

            //直播所需要的声明,iOS10必须
            rootDict.SetString("NSContactsUsageDescription", "App需要您的同意,才能访问通讯录");
            rootDict.SetString("NSCalendarsUsageDescription", "App需要您的同意,才能访问日历");
            rootDict.SetString("NSCameraUsageDescription", "App需要您的同意,才能使用相机");
            rootDict.SetString("NSLocationUsageDescription", "App需要您的同意,才能访问位置");
            rootDict.SetString("NSLocationWhenInUseUsageDescription", "App需要您的同意,才能在使用期间访问位置");
            rootDict.SetString("NSLocationAlwaysUsageDescription", "App需要您的同意,才能始终访问位置");
            rootDict.SetString("NSMicrophoneUsageDescription", "App需要您的同意,才能使用麦克风");
            rootDict.SetString("NSPhotoLibraryUsageDescription", "App需要您的同意,才能访问相册");

            // LSApplicationQueriesSchemes
            var queriesSchemes = rootDict.CreateArray("LSApplicationQueriesSchemes");

            queriesSchemes.AddString("mqqapi");
            queriesSchemes.AddString("mqqopensdkapiV4");
            queriesSchemes.AddString("mqqopensdkapiV3");
            queriesSchemes.AddString("mqqopensdkapiV2");
            queriesSchemes.AddString("mqqapiwallet");
            queriesSchemes.AddString("mqqwpa");
            queriesSchemes.AddString("mqqbrowser");
            queriesSchemes.AddString("weixin");
            queriesSchemes.AddString("wechat");
            queriesSchemes.AddString("mqqOpensdkSSoLogin");
            queriesSchemes.AddString("mqzone");
            queriesSchemes.AddString("sinaweibo");
            queriesSchemes.AddString("sinaweibohd");
            queriesSchemes.AddString("sinaweibo");
            queriesSchemes.AddString("weibosdk");
            queriesSchemes.AddString("weibosdk2.5");
            queriesSchemes.AddString("mqq");
            queriesSchemes.AddString("mqzoneopensdk");

            //CFBundleURLTypes
            var urlTypes = rootDict.CreateArray("CFBundleURLTypes");

            //weibo
            var dictWeibo = urlTypes.AddDict();

            dictWeibo.SetString("CFBundleTypeRole", "Editor");
            dictWeibo.SetString("CFBundleURLName", "com.weibo");
            var dictWeiboDic = dictWeibo.CreateArray("CFBundleURLSchemes");

            dictWeiboDic.AddString("wb639535745");

            //weixin
            var dictWeiXin = urlTypes.AddDict();

            dictWeiXin.SetString("CFBundleTypeRole", "Editor");
            dictWeiXin.SetString("CFBundleURLName", "");
            var dictWeiXinDic = dictWeiXin.CreateArray("CFBundleURLSchemes");

            dictWeiXinDic.AddString("wxb80d3faba4d24a1c");

            //qq
            var dictQQ1 = urlTypes.AddDict();

            dictQQ1.SetString("CFBundleTypeRole", "Editor");
            dictQQ1.SetString("CFBundleURLName", "");
            var dictQQDic1 = dictQQ1.CreateArray("CFBundleURLSchemes");

            dictQQDic1.AddString("tencent1105220627");

            var dictQQ2 = urlTypes.AddDict();

            dictQQ2.SetString("CFBundleTypeRole", "Editor");
            dictQQ2.SetString("CFBundleURLName", "");
            var dictQQDic2 = dictQQ2.CreateArray("CFBundleURLSchemes");

            dictQQDic2.AddString("QQ1105220627");

            // 保存plist
            plist.WriteToFile(plistPath);
        }
示例#27
0
        public static void OnPostProcessBuild(BuildTarget target, string path)
        {
            var pbxProjectPath = UnityEditor.iOS.Xcode.PBXProject.GetPBXProjectPath(path);
            var pbxProject     = new UnityEditor.iOS.Xcode.PBXProject();

            pbxProject.ReadFromString(System.IO.File.ReadAllText(pbxProjectPath));

            Debug.Log("TTPPostProcessSettings::Add swift support for mopub and ecpm");
            pbxProject.AddBuildProperty(GetTargetGUID(pbxProject), "LIBRARY_SEARCH_PATHS", "$(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME)");
            pbxProject.AddBuildProperty(GetTargetGUID(pbxProject), "LIBRARY_SEARCH_PATHS", "$(SDKROOT)/usr/lib/swift");
            pbxProject.SetBuildProperty(GetTargetGUID(pbxProject), "LD_RUNPATH_SEARCH_PATHS", "/usr/lib/swift $(inherited) @executable_path/Frameworks");
            pbxProject.SetBuildProperty(GetTargetGUID(pbxProject), "ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES", "YES");
            pbxProject.SetBuildProperty(GetTargetGUID(pbxProject), "SWIFT_VERSION", "5");
#if UNITY_2019_3_OR_NEWER
            var unityFrameworkTarget = pbxProject.GetUnityFrameworkTargetGuid();
            pbxProject.AddBuildProperty(unityFrameworkTarget, "LIBRARY_SEARCH_PATHS", "$(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME)");
            pbxProject.AddBuildProperty(unityFrameworkTarget, "LIBRARY_SEARCH_PATHS", "$(SDKROOT)/usr/lib/swift");
            pbxProject.SetBuildProperty(unityFrameworkTarget, "LD_RUNPATH_SEARCH_PATHS", "/usr/lib/swift $(inherited) @executable_path/Frameworks");
            pbxProject.SetBuildProperty(unityFrameworkTarget, "ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES", "NO");
            pbxProject.SetBuildProperty(unityFrameworkTarget, "SWIFT_VERSION", "5");

            var mainTargetLinkFrameworksId   = pbxProject.GetFrameworksBuildPhaseByTarget(pbxProject.GetUnityMainTargetGuid());
            var unityFrameworkBuildProductId = pbxProject.GetTargetProductFileRef(pbxProject.GetUnityFrameworkTargetGuid());
            Debug.Log("Linking unity framework to main target to support unity 2020 - " + mainTargetLinkFrameworksId + ", " + unityFrameworkBuildProductId);
            pbxProject.AddFileToBuildSection(pbxProject.GetUnityMainTargetGuid(), mainTargetLinkFrameworksId, unityFrameworkBuildProductId);
#endif

#if UNITY_2019_3_OR_NEWER
            //Add BUAdASDK.bundle
            string pathToBUAdSDK    = "Data/Raw/Bundle/BUAdSDK.bundle";
            string absPathToBUADSDK = Path.Combine(path, pathToBUAdSDK);

            if (Directory.Exists(absPathToBUADSDK))
            {
                Debug.Log("TTPPostProcessSettings :: Adding BUAdSDK.bundle");
                pbxProject.AddFileToBuild(GetTargetGUID(pbxProject), pbxProject.AddFile(pathToBUAdSDK, "BUAdSDK.bundle"));
            }
            else
            {
                Debug.Log("TTPPostProcessSettings :: BUAdSDK.bundle not exists");
            }
            //END BUAdSDK

            string pathToTapJoyBundle  = "Data/Raw/Bundle/TapjoyResources.bundle";
            string absPathTapJoyBundle = Path.Combine(path, pathToBUAdSDK);

            if (Directory.Exists(absPathTapJoyBundle))
            {
                Debug.Log("TTPPostProcessSettings :: Adding TapjoyResources.bundle");
                pbxProject.AddFileToBuild(GetTargetGUID(pbxProject), pbxProject.AddFile(pathToTapJoyBundle, "TapjoyResources.bundle"));
            }
            else
            {
                Debug.Log("TTPAddTiktokBundle.cs :: TapjoyResources.bundle not exists");
            }
#endif

            File.WriteAllText(pbxProjectPath, pbxProject.WriteToString());

            var plistPath = Path.Combine(path, "Info.plist");
            var plist     = new PlistDocument();
            plist.ReadFromFile(plistPath);
            rootDict = plist.root;

            rootDict.SetBoolean("GOOGLE_ANALYTICS_DEFAULT_ALLOW_AD_PERSONALIZATION_SIGNALS", false);
            rootDict.SetBoolean("FIREBASE_ANALYTICS_COLLECTION_ENABLED", false);


            // Add AppLovinSdkKey
            if (Application.identifier == "com.tabtaleint.ttplugins" ||
                Application.identifier == "com.tabtaleint.ttplugins" ||
                Application.identifier == "com.tabtaleint.ttplugins")
            {
                rootDict.SetString("AppLovinSdkKey", "yRHC8kgWwG5S4lOh7Dx_pZB2iEBLVWMSzde5MKbGahifQ6MTKIT7tk9ZzLvTsFwptZvDuVTTBB8cHU9bohkeQu");
            }
            else
            {
                rootDict.SetString("AppLovinSdkKey", "TREvWeSbneklepMTdxWL5KCqUD57xezP4CIarlBcOwM1kiVMe0hkLvTq7dy3HwSL6mxyV7Tu1wwlcP5FQo-nhW");
            }


            var array = rootDict.CreateArray("SKAdNetworkItems");
            //admob
            array.AddDict().SetString("SKAdNetworkIdentifier", "cstr6suwn9.skadnetwork");
            //applovin
            array.AddDict().SetString("SKAdNetworkIdentifier", "ludvb6z3bs.skadnetwork");
            //ironsource
            array.AddDict().SetString("SKAdNetworkIdentifier", "su67r6k2v3.skadnetwork");
            //adcolony
            array.AddDict().SetString("SKAdNetworkIdentifier", "4pfyvq9l8r.skadnetwork");
            array.AddDict().SetString("SKAdNetworkIdentifier", "4fzdc2evr5.skadnetwork");
            array.AddDict().SetString("SKAdNetworkIdentifier", "4468km3ulz.skadnetwork");
            array.AddDict().SetString("SKAdNetworkIdentifier", "3rd42ekr43.skadnetwork");
            array.AddDict().SetString("SKAdNetworkIdentifier", "m8dbw4sv7c.skadnetwork");
            array.AddDict().SetString("SKAdNetworkIdentifier", "ejvt5qm6ak.skadnetwork");
            array.AddDict().SetString("SKAdNetworkIdentifier", "mtkv5xtk9e.skadnetwork");
            //chartboost
            array.AddDict().SetString("SKAdNetworkIdentifier", "f38h382jlk.skadnetwork");
            //facebook
            array.AddDict().SetString("SKAdNetworkIdentifier", "v9wttpbfk9.skadnetwork");
            array.AddDict().SetString("SKAdNetworkIdentifier", "n38lu8286q.skadnetwork");
            //hypermx
            array.AddDict().SetString("SKAdNetworkIdentifier", "nu4557a4je.skadnetwork");
            //inmobi
            array.AddDict().SetString("SKAdNetworkIdentifier", "wzmmz9fp6w.skadnetwork");
            array.AddDict().SetString("SKAdNetworkIdentifier", "uw77j35x4d.skadnetwork");
            array.AddDict().SetString("SKAdNetworkIdentifier", "7ug5zh24hu.skadnetwork");
            array.AddDict().SetString("SKAdNetworkIdentifier", "hs6bdukanm.skadnetwork");
            array.AddDict().SetString("SKAdNetworkIdentifier", "ggvn48r87g.skadnetwork");
            array.AddDict().SetString("SKAdNetworkIdentifier", "5lm9lj6jb7.skadnetwork");
            array.AddDict().SetString("SKAdNetworkIdentifier", "9rd848q2bz.skadnetwork");
            array.AddDict().SetString("SKAdNetworkIdentifier", "c6k4g5qg8m.skadnetwork");
            array.AddDict().SetString("SKAdNetworkIdentifier", "3sh42y64q3.skadnetwork");
            array.AddDict().SetString("SKAdNetworkIdentifier", "yclnxrl5pm.skadnetwork");
            array.AddDict().SetString("SKAdNetworkIdentifier", "f73kdq92p3.skadnetwork");
            array.AddDict().SetString("SKAdNetworkIdentifier", "ydx93a7ass.skadnetwork");
            array.AddDict().SetString("SKAdNetworkIdentifier", "w9q455wk68.skadnetwork");
            array.AddDict().SetString("SKAdNetworkIdentifier", "prcb7njmu6.skadnetwork");
            array.AddDict().SetString("SKAdNetworkIdentifier", "wg4vff78zm.skadnetwork");
            array.AddDict().SetString("SKAdNetworkIdentifier", "mlmmfzh3r3.skadnetwork");
            array.AddDict().SetString("SKAdNetworkIdentifier", "tl55sbb4fm.skadnetwork");
            array.AddDict().SetString("SKAdNetworkIdentifier", "t38b2kh725.skadnetwork");
            array.AddDict().SetString("SKAdNetworkIdentifier", "5l3tpt7t6e.skadnetwork");
            array.AddDict().SetString("SKAdNetworkIdentifier", "7rz58n8ntl.skadnetwork");
            array.AddDict().SetString("SKAdNetworkIdentifier", "klf5c3l5u5.skadnetwork");
            array.AddDict().SetString("SKAdNetworkIdentifier", "cg4yq2srnc.skadnetwork");
            array.AddDict().SetString("SKAdNetworkIdentifier", "av6w8kgt66.skadnetwork");
            array.AddDict().SetString("SKAdNetworkIdentifier", "9t245vhmpl.skadnetwork");
            array.AddDict().SetString("SKAdNetworkIdentifier", "v72qych5uu.skadnetwork");
            array.AddDict().SetString("SKAdNetworkIdentifier", "2u9pt9hc89.skadnetwork");
            array.AddDict().SetString("SKAdNetworkIdentifier", "44jx6755aq.skadnetwork");
            array.AddDict().SetString("SKAdNetworkIdentifier", "8s468mfl3y.skadnetwork");
            array.AddDict().SetString("SKAdNetworkIdentifier", "p78axxw29g.skadnetwork");
            array.AddDict().SetString("SKAdNetworkIdentifier", "ppxm28t8ap.skadnetwork");
            //mintegral
            array.AddDict().SetString("SKAdNetworkIdentifier", "kbd757ywx3.skadnetwork");
            array.AddDict().SetString("SKAdNetworkIdentifier", "glqzh8vgby.skadnetwork");
            array.AddDict().SetString("SKAdNetworkIdentifier", "6xzpu9s2p8.skadnetwork");
            //pangle
            array.AddDict().SetString("SKAdNetworkIdentifier", "22mmun2rn5.skadnetwork"); //non cn
            array.AddDict().SetString("SKAdNetworkIdentifier", "238da6jt44.skadnetwork"); //cn
            //tapjoy
            array.AddDict().SetString("SKAdNetworkIdentifier", "ecpz2srf59.skadnetwork");
            array.AddDict().SetString("SKAdNetworkIdentifier", "578prtvx9j.skadnetwork");
            //unity ads
            array.AddDict().SetString("SKAdNetworkIdentifier", "4dzt52r2t5.skadnetwork");
            array.AddDict().SetString("SKAdNetworkIdentifier", "488r3q3dtq.skadnetwork");
            array.AddDict().SetString("SKAdNetworkIdentifier", "zmvfpc5aq8.skadnetwork");
            array.AddDict().SetString("SKAdNetworkIdentifier", "v79kvwwj4g.skadnetwork");
            array.AddDict().SetString("SKAdNetworkIdentifier", "lr83yxwka7.skadnetwork");
            array.AddDict().SetString("SKAdNetworkIdentifier", "44n7hlldy6.skadnetwork");
            array.AddDict().SetString("SKAdNetworkIdentifier", "424m5254lk.skadnetwork");
            //vungle
            array.AddDict().SetString("SKAdNetworkIdentifier", "gta9lk7p23.skadnetwork");
            //mopub
            array.AddDict().SetString("SKAdNetworkIdentifier", "cdkw7geqsh.skadnetwork");
            array.AddDict().SetString("SKAdNetworkIdentifier", "qyjfv329m4.skadnetwork");
            array.AddDict().SetString("SKAdNetworkIdentifier", "3qy4746246.skadnetwork");
            array.AddDict().SetString("SKAdNetworkIdentifier", "523jb4fst2.skadnetwork");
            array.AddDict().SetString("SKAdNetworkIdentifier", "5a6flpkh64.skadnetwork");
            array.AddDict().SetString("SKAdNetworkIdentifier", "737z793b9f.skadnetwork");
            array.AddDict().SetString("SKAdNetworkIdentifier", "7953jerfzd.skadnetwork");
            array.AddDict().SetString("SKAdNetworkIdentifier", "97r2b46745.skadnetwork");
            array.AddDict().SetString("SKAdNetworkIdentifier", "9yg77x724h.skadnetwork");
            array.AddDict().SetString("SKAdNetworkIdentifier", "bvpn9ufa9b.skadnetwork");
            array.AddDict().SetString("SKAdNetworkIdentifier", "cj5566h2ga.skadnetwork");
            array.AddDict().SetString("SKAdNetworkIdentifier", "gvmwg8q7h5.skadnetwork");
            array.AddDict().SetString("SKAdNetworkIdentifier", "mls7yz5dvl.skadnetwork");
            array.AddDict().SetString("SKAdNetworkIdentifier", "n66cz3y3bx.skadnetwork");
            array.AddDict().SetString("SKAdNetworkIdentifier", "n9x2a789qt.skadnetwork");
            array.AddDict().SetString("SKAdNetworkIdentifier", "nzq8sh4pbs.skadnetwork");
            array.AddDict().SetString("SKAdNetworkIdentifier", "pu4na253f3.skadnetwork");
            array.AddDict().SetString("SKAdNetworkIdentifier", "u679fj5vs4.skadnetwork");
            array.AddDict().SetString("SKAdNetworkIdentifier", "xy9t38ct57.skadnetwork");
            array.AddDict().SetString("SKAdNetworkIdentifier", "z4gj7hsk7h.skadnetwork");

            array.AddDict().SetString("SKAdNetworkIdentifier", "s39g8k73mm.skadnetwork");
            array.AddDict().SetString("SKAdNetworkIdentifier", "24t9a8vw3c.skadnetwork");
            array.AddDict().SetString("SKAdNetworkIdentifier", "yrqqpx2mcb.skadnetwork");
            array.AddDict().SetString("SKAdNetworkIdentifier", "52fl2v3hgk.skadnetwork");



            // fix problem with statusbar on iOS 14
            if (!rootDict.values.ContainsKey("UIViewControllerBasedStatusBarAppearance"))
            {
                rootDict.SetBoolean("UIViewControllerBasedStatusBarAppearance", false);
            }


            File.WriteAllText(plistPath, plist.WriteToString());
        }
示例#28
0
    public static void OnPostProcessBuild(BuildTarget buildTarget, string path)
    {
        if (buildTarget == BuildTarget.iOS)
        {
#if UNITY_IOS
            //localization
            NativeLocale.AddLocalizedStringsIOS(path, Path.Combine(Application.dataPath, "NativeLocale/iOS"));
            SushiDebug.Log("DEBUG_________Application datapath:" + Application.dataPath);
            string projectPath = path + "/Unity-iPhone.xcodeproj/project.pbxproj";

            PBXProject pbxProject = new PBXProject();
            pbxProject.ReadFromFile(projectPath);

            // Facebook SDK가 Bitcode 미지원하므로 이 플래그를 꺼야 빌드가 된다.
            //string target = pbxProject.TargetGuidByName("Unity-iPhone");
            string target = pbxProject.GetUnityMainTargetGuid();
            pbxProject.SetBuildProperty(target, "ENABLE_BITCODE", "NO");
            // 로컬 알림 관련해서 아래 프레임워크가 추가 되어야 한다.
            pbxProject.AddFrameworkToProject(target, "UserNotifications.framework", false);

            pbxProject.AddCapability(target, PBXCapabilityType.iCloud);
            pbxProject.AddCapability(target, PBXCapabilityType.GameCenter);
            pbxProject.AddCapability(target, PBXCapabilityType.InAppPurchase);

            pbxProject.WriteToFile(projectPath);

            var plistPath = Path.Combine(path, "Info.plist");
            var plist     = new PlistDocument();
            plist.ReadFromFile(plistPath);
            // 수출 관련 규정 플래그 추가 (AppStore 제출 시 필요하다고 안내하고 있음)
            plist.root.SetBoolean("ITSAppUsesNonExemptEncryption", false);
            // 스크린샷을 앨범에 저장하고자 할 때 필요한 권한을 요청하는 팝업 설정 (지정하지 않으면 크래시)
            plist.root.SetString("NSPhotoLibraryUsageDescription", "Screenshot Save");
            plist.root.SetString("NSPhotoLibraryAddUsageDescription", "Screenshot Save");
            // 최신 AdMob SDK에서는 아래 항목이 필수다...헛헛헛...
            plist.root.SetString("GADApplicationIdentifier", "ca-app-pub-5072035175916776~2508482457");

            // https://developers.google.com/ad-manager/mobile-ads-sdk/ios/quick-start#update_your_infoplist
            plist.root.SetBoolean("GADIsAdManagerApp", true);
            // ERROR ITMS-90503: "Invalid Bundle. You've included the "arm64" value for the UIRequiredDeviceCapabilities key in your Xcode project, indicating that your app may only support 64-bit. Your binary, 'com.pronetizen.sushi', must only contain the 64-bit architecture slice. Learn more (https://developer.apple.com/library/content/documentation/General/Reference/InfoPlistKeyReference/Articles/iPhoneOSKeys.html#//apple_ref/doc/uid/TP40009252-SW3)."
            var devCapArray = plist.root["UIRequiredDeviceCapabilities"].AsArray();
            devCapArray.values = devCapArray.values.Where(e => e.AsString() != "arm64").ToList();
            plist.root["UIRequiredDeviceCapabilities"] = devCapArray;

            plist.root.SetString("NSUserTrackingUsageDescription", TrackingDescription);
            plist.WriteToFile(plistPath);

            // Copy entitlements file
            System.IO.File.Copy("balloon.entitlements", path + "/balloon.entitlements", true);

            // https://stackoverflow.com/questions/55419956/how-to-fix-pod-does-not-support-provisioning-profiles-in-azure-devops-build
            var podfileAppend = @"
post_install do |installer|
    installer.pods_project.targets.each do |target|
        target.build_configurations.each do |config|
            config.build_settings['CODE_SIGN_STYLE'] = ""Automatic"";
        end
    end
end
";
            File.AppendAllText($"{path}/Podfile", podfileAppend);
#endif
        }
    }
示例#29
0
    public static void OnPostprocessBuild(BuildTarget buildTarget, string path)
    {
        if (buildTarget == BuildTarget.iOS)
        {
            string projPath = path + "/Unity-iPhone.xcodeproj/project.pbxproj";

            PBXProject proj = new PBXProject();
            proj.ReadFromFile(projPath);
            string target = proj.TargetGuidByName("Unity-iPhone");

            // Add Frameworks
            proj.AddFrameworkToProject(target, "Accelerate.framework", false);
            proj.AddFrameworkToProject(target, "Metal.framework", false);
            proj.AddFrameworkToProject(target, "GLKit.framework", false);
            proj.AddFrameworkToProject(target, "ARKit.framework", true);

            // Disable use of Bitcode
            proj.SetBuildProperty(target, "ENABLE_BITCODE", "NO");

            // Only generate 64bit variants, so set Valid Archs to only "arm64"
            //proj.SetBuildProperty(target, "ARCHS", "arm64");
            //proj.SetBuildProperty(target, "VALID_ARCHS", "arm64");
            proj.UpdateBuildProperty(target, "ARCHS",
                                     new string[] {}, new string[] { "armv7", "armv7s", "armv7" });
            proj.UpdateBuildProperty(target, "VALID_ARCHS",
                                     new string[] { "arm64" }, new string[] { "armv7", "armv7s" });

            // Compile libz and xml2 along with project
            proj.UpdateBuildProperty(target, "OTHER_LDFLAGS",
                                     new string[] { "-lz", "-lxml2" }, new string[] {});

            proj.WriteToFile(projPath);

            // Since iOS 10 it's necessary to add a reason for accessing the
            // camera to Info.plist. Newer version of Unity allow to set the
            // usage description inside the editor. For older Versions of
            // Unity, we add a default value automatically.

            // Get plist
            string        plistPath = path + "/Info.plist";
            PlistDocument plist     = new PlistDocument();
            plist.ReadFromString(File.ReadAllText(plistPath));

            // Get root
            PlistElementDict rootDict = plist.root;

            // Set usage description, if not set already
            string cameraUsageDescriptionKey =
                "Privacy - Camera Usage Description";
            string cameraUsageDescriptionValue =
                "Augmented Reality";
            PlistElementString cameraUsageDescriptionEl =
                (PlistElementString)rootDict[cameraUsageDescriptionKey];
            if (cameraUsageDescriptionEl == null)
            {
                rootDict.SetString(cameraUsageDescriptionKey,
                                   cameraUsageDescriptionValue);
                File.WriteAllText(plistPath, plist.WriteToString());
            }
            else if (String.IsNullOrEmpty(cameraUsageDescriptionEl.value))
            {
                cameraUsageDescriptionEl.value = cameraUsageDescriptionValue;
                File.WriteAllText(plistPath, plist.WriteToString());
            }
        }
    }
示例#30
0
    public static void OnPostprocessBuild(BuildTarget buildTarget, string path)
    {
        if (buildTarget == BuildTarget.iOS)
        {
            if (!useThis)
            {
                return;
            }

            string     projPath = path + "/Unity-iPhone.xcodeproj/project.pbxproj";
            PBXProject proj     = new PBXProject();
            proj.ReadFromString(File.ReadAllText(projPath));

            string plistPath = Path.Combine(path, "Info.plist");
            var    plist     = new PlistDocument();
            plist.ReadFromFile(plistPath);

            string target          = proj.TargetGuidByName("Unity-iPhone");
            string frameworkSuffix = (is_iOS9orOver) ? "tbd" : "dylib";

            //Adfurikunの、必要な標準frameworkを追加します。
            proj.AddFrameworkToProject(target, "SystemConfiguration.framework", false);
            proj.AddFrameworkToProject(target, "AdSupport.framework", false);
            proj.AddFrameworkToProject(target, "WebKit.framework", false);
            //
            //アドネットワークごとの、必要な標準frameworkを追加します。
            //AppLovin
            if (use_AppLovin)
            {
                proj.AddFrameworkToProject(target, "AdSupport.framework", false);
                proj.AddFrameworkToProject(target, "AVFoundation.framework", false);
                proj.AddFrameworkToProject(target, "CoreTelephony.framework", false);
                proj.AddFrameworkToProject(target, "CoreGraphics.framework", false);
                proj.AddFrameworkToProject(target, "CoreMedia.framework", false);
                proj.AddFrameworkToProject(target, "MediaPlayer.framework", false);
                proj.AddFrameworkToProject(target, "SystemConfiguration.framework", false);
                proj.AddFrameworkToProject(target, "StoreKit.framework", false);
                proj.AddFrameworkToProject(target, "UIKit.framework", false);
            }

            //AdColony
            if (use_AdColony)
            {
                proj.AddFrameworkToProject(target, "AdSupport.framework", false);
                proj.AddFrameworkToProject(target, "AudioToolbox.framework", false);
                proj.AddFrameworkToProject(target, "AVFoundation.framework", false);
                proj.AddFrameworkToProject(target, "CoreTelephony.framework", false);
                proj.AddFrameworkToProject(target, "EventKit.framework", false);
                proj.AddFrameworkToProject(target, "JavaScriptCore.framework", true);                 //Optional
                proj.AddFrameworkToProject(target, "MessageUI.framework", false);
                proj.AddFrameworkToProject(target, "Social.framework", false);
                proj.AddFrameworkToProject(target, "StoreKit.framework", false);
                proj.AddFrameworkToProject(target, "SystemConfiguration.framework", false);
                proj.AddFrameworkToProject(target, "WatchConnectivity.framework", true);     //Optional
                proj.AddFrameworkToProject(target, "WebKit.framework", true);                //Optional
                proj.AddFileToBuild(target, proj.AddFile(
                                        "usr/lib/libz.1.2.5." + frameworkSuffix, "libz.1.2.5." + frameworkSuffix, PBXSourceTree.Sdk));

                //プライバシー設定
                plist.root.SetString("NSCalendarsUsageDescription", "Adding events");
                plist.root.SetString("NSPhotoLibraryUsageDescription", "Taking selfies");
                plist.root.SetString("NSCameraUsageDescription", "Taking selfies");
                plist.root.SetString("NSMotionUsageDescription", "Interactive ad controls");
            }

            //UnityAds
            if (use_UnityAds)
            {
                proj.AddFrameworkToProject(target, "AdSupport.framework", false);
                proj.AddFrameworkToProject(target, "AVFoundation.framework", false);
                proj.AddFrameworkToProject(target, "StoreKit.framework", false);
                proj.AddFrameworkToProject(target, "CFNetwork.framework", false);
                proj.AddFrameworkToProject(target, "CoreFoundation.framework", false);
                proj.AddFrameworkToProject(target, "CoreMedia.framework", false);
                proj.AddFrameworkToProject(target, "CoreTelephony.framework", false);
                proj.AddFrameworkToProject(target, "SystemConfiguration.framework", false);
            }

            //Maio
            if (use_Maio)
            {
                proj.AddFrameworkToProject(target, "MobileCoreServices.framework", false);
                proj.AddFrameworkToProject(target, "CoreMedia.framework", false);
            }

            //TapJoy
            if (use_Tapjoy)
            {
                proj.AddFrameworkToProject(target, "AdSupport.framework", false);
                proj.AddFrameworkToProject(target, "CFNetwork.framework", false);
                proj.AddFrameworkToProject(target, "CoreData.framework", false);
                proj.AddFrameworkToProject(target, "CoreGraphics.framework", false);
                proj.AddFrameworkToProject(target, "CoreLocation.framework", false);
                proj.AddFrameworkToProject(target, "CoreMotion.framework", false);
                proj.AddFrameworkToProject(target, "CoreTelephony.framework", false);
                proj.AddFrameworkToProject(target, "EventKit.framework", false);
                proj.AddFrameworkToProject(target, "EventKitUI.framework", false);
                proj.AddFrameworkToProject(target, "Foundation.framework", false);
                proj.AddFrameworkToProject(target, "MapKit.framework", false);
                proj.AddFrameworkToProject(target, "MediaPlayer.framework", false);
                proj.AddFrameworkToProject(target, "MessageUI.framework", false);
                proj.AddFrameworkToProject(target, "MobileCoreServices.framework", false);
                proj.AddFrameworkToProject(target, "PassKit.framework", true);                //Optional
                proj.AddFrameworkToProject(target, "QuartzCore.framework", false);
                proj.AddFrameworkToProject(target, "Security.framework", false);
                proj.AddFrameworkToProject(target, "Social.framework", true);                //Optional
                proj.AddFrameworkToProject(target, "StoreKit.framework", false);
                proj.AddFrameworkToProject(target, "SystemConfiguration.framework", false);
                proj.AddFrameworkToProject(target, "Twitter.framework", false);
                proj.AddFrameworkToProject(target, "UIKit.framework", false);
                proj.AddFrameworkToProject(target, "ImageIO.framework", false);
                proj.AddFileToBuild(target, proj.AddFile(
                                        "usr/lib/libxml2." + frameworkSuffix, "libxml2." + frameworkSuffix, PBXSourceTree.Sdk));
                proj.AddFileToBuild(target, proj.AddFile(
                                        "usr/lib/libc++." + frameworkSuffix, "libc++." + frameworkSuffix, PBXSourceTree.Sdk));
                proj.AddFileToBuild(target, proj.AddFile(
                                        "usr/lib/libz.1.2.5." + frameworkSuffix, "libz.1.2.5." + frameworkSuffix, PBXSourceTree.Sdk));
                proj.AddFileToBuild(target, proj.AddFile(
                                        "usr/lib/libsqlite3.0." + frameworkSuffix, "libsqlite3.0." + frameworkSuffix, PBXSourceTree.Sdk));
            }

            //Vungle
            if (use_Vungle)
            {
                proj.AddFrameworkToProject(target, "AdSupport.framework", false);
                proj.AddFrameworkToProject(target, "AudioToolbox.framework", false);
                proj.AddFrameworkToProject(target, "AVFoundation.framework", false);
                proj.AddFrameworkToProject(target, "CFNetwork.framework", false);
                proj.AddFrameworkToProject(target, "CoreGraphics.framework", false);
                proj.AddFrameworkToProject(target, "CoreMedia.framework", false);
                proj.AddFrameworkToProject(target, "Foundation.framework", false);
                proj.AddFrameworkToProject(target, "MediaPlayer.framework", false);
                proj.AddFrameworkToProject(target, "QuartzCore.framework", false);
                proj.AddFrameworkToProject(target, "StoreKit.framework", false);
                proj.AddFrameworkToProject(target, "SystemConfiguration.framework", false);
                proj.AddFrameworkToProject(target, "UIKit.framework", false);
                proj.AddFrameworkToProject(target, "WebKit.framework", true);                //Optional
                proj.AddFileToBuild(target, proj.AddFile(
                                        "usr/lib/libz.1.2.5." + frameworkSuffix, "libz.1.2.5." + frameworkSuffix, PBXSourceTree.Sdk));
                proj.AddFileToBuild(target, proj.AddFile(
                                        "usr/lib/libsqlite3.0." + frameworkSuffix, "libsqlite3.0." + frameworkSuffix, PBXSourceTree.Sdk));
            }

            //SMAAD Video
            if (use_SmaadVideo)
            {
                proj.AddFrameworkToProject(target, "MediaPlayer.framework", false);
                proj.AddFrameworkToProject(target, "AdSupport.framework", false);
                proj.AddFrameworkToProject(target, "SystemConfiguration.framework", false);
                //SmaADは、バージョン1.1.3の時点ではbitcodeに対応しておりません
                proj.SetBuildProperty(target, "ENABLE_BITCODE", "NO");
            }

            //Five
            if (use_Five)
            {
                proj.AddFrameworkToProject(target, "AdSupport.framework", false);
                proj.AddFrameworkToProject(target, "AVFoundation.framework", false);
                proj.AddFrameworkToProject(target, "CoreMedia.framework", false);
                proj.AddFrameworkToProject(target, "CoreTelephony.framework", false);
                proj.AddFrameworkToProject(target, "SystemConfiguration.framework", false);
            }

            //nend
            if (use_Nend)
            {
                proj.AddFrameworkToProject(target, "AdSupport.framework", false);
                proj.AddFrameworkToProject(target, "Security.framework", false);
                proj.AddFrameworkToProject(target, "ImageIO.framework", false);
                proj.AddFrameworkToProject(target, "AVFoundation.framework", false);
                proj.AddFrameworkToProject(target, "CoreMedia.framework", false);
                proj.AddFrameworkToProject(target, "SystemConfiguration.framework", false);
                proj.AddFrameworkToProject(target, "WebKit.framework", true);                  //Optional
                proj.AddFrameworkToProject(target, "CoreLocation.framework", false);
                proj.AddFrameworkToProject(target, "CoreMotion.framework", false);
                proj.AddFrameworkToProject(target, "CoreTelephony.framework", false);
            }

            // フレームワーク検索パスの設定
            proj.SetBuildProperty(target, "FRAMEWORK_SEARCH_PATHS", "$(inherited)");
            // Frameworks/Plugins/iOS/**/*.framework
            // Use ** to make search setting in Xcode recursive
            proj.AddBuildProperty(target, "FRAMEWORK_SEARCH_PATHS", "$(PROJECT_DIR)/Frameworks/Plugins/iOS/**");

            //エクスポート時に文字列のパスが加えられること(Unity由来の事象)への対応
            proj.UpdateBuildProperty(target, "HEADER_SEARCH_PATHS",
                                     new string[] { "$(SRCROOT)/Classes", "$(SRCROOT)" }, new string[] { "\"$(SRCROOT)/Classes\"", "\"$(SRCROOT)\"" });
            proj.UpdateBuildProperty(target, "LIBRARY_SEARCH_PATHS",
                                     new string[] { "$(SRCROOT)/Classes", "$(SRCROOT)" }, new string[] { "\"$(SRCROOT)/Classes\"", "\"$(SRCROOT)\"" });
            // Set a custom link flag
            proj.AddBuildProperty(target, "OTHER_LDFLAGS", "-ObjC");
            proj.AddBuildProperty(target, "OTHER_LDFLAGS", "-fobjc-arc");

            // ソースのコンパイルフラグに "-fobjc-arc" を追加
            foreach (string filePath in new string[] {
                "Libraries/Plugins/iOS/ADFMovieRewardAdViewController.mm",
                "Libraries/Plugins/iOS/ADFMovieRewardUnityAdapter.m",
                "Libraries/Plugins/iOS/ADFMovieInterstitialAdViewController.mm",
                "Libraries/Plugins/iOS/ADFMovieInterstitialUnityAdapter.m",
                "Libraries/Plugins/iOS/ADFMovieNativeAdViewManager.mm",
                "Libraries/Plugins/iOS/ADFMovieNativeAdViewUnityAdapter.m"
            })
            {
                string fileGuid = proj.FindFileGuidByProjectPath(filePath);
                var    flags    = proj.GetCompileFlagsForFile(target, fileGuid);
                flags.Remove("-fobjc-arc");
                flags.Add("-fobjc-arc");
                proj.SetCompileFlagsForFile(target, fileGuid, flags);
            }
            //Debug.Log(target);
            File.WriteAllText(projPath, proj.WriteToString());
            plist.WriteToFile(plistPath);
        }
    }
 private static void DisableViewControllerBasedStatusBar(PlistDocument plistDocument)
 {
     plistDocument.root.SetString("UIViewControllerBasedStatusBarAppearance", "NO");
 }
示例#32
0
    public static void OnPostprocessBuild(BuildTarget target, string pathToBuiltProject)
    {
        Debug.Log("GveBuild.OnPostprocessBuild " + target + " " + pathToBuiltProject);
        switch (target)
        {
        case BuildTarget.iOS:
            string plistFilePath = pathToBuiltProject + Path.DirectorySeparatorChar + "Info.plist";
            // 10/5/16 The code that uses Xcode is flagged as missing in editor, but it compiles when we return to Unity and works
            // when build is run.
            // Q: why doesn't this work? A: 2nd link says it is fixed in 5.4.2, we'll see
            // https://issuetracker.unity3d.com/issues/ios-monodevelop-unityeditor-dot-ios-dot-xcode-namespace-isnt-recognised-in-monodevelop
            // https://issuetracker.unity3d.com/issues/unity-does-not-include-unityeditor-dot-ios-dot-xcode-in-project-file

            // Read the existing plist file
            try {
                PlistDocument plist = new PlistDocument();
                plist.ReadFromFile(plistFilePath);
                Debug.Log("GveBuild.OnPostprocessBuild successfully read " + plistFilePath + ": " + ValueToString(plist.root));

                // Add our modifications
                if (plist.root.values.ContainsKey(NSCameraUsageDescription))
                {
                    Debug.LogError("GveBuild.OnPostprocessBuild key already set? Do not overwrite: " + NSCameraUsageDescription + " = " + ValueToString(plist.root.values[NSCameraUsageDescription]));
                }
                else
                {
                    plist.root.values[NSCameraUsageDescription] = new PlistElementString("Camera is not used by our application (API reference is due to Unity libraries)");
                    Debug.Log("GveBuild.OnPostprocessBuild added NSCameraUsageDescription = " + ValueToString(plist.root.values[NSCameraUsageDescription]));
                }

                if (plist.root.values.ContainsKey(NSPhotoLibraryUsageDescription))
                {
                    Debug.LogError("GveBuild.OnPostprocessBuild key already set? Do not overwrite: " + NSPhotoLibraryUsageDescription + " = " + ValueToString(plist.root.values[NSPhotoLibraryUsageDescription]));
                }
                else
                {
                    plist.root.values[NSPhotoLibraryUsageDescription] = new PlistElementString("PhotoLibrary is not used by our application (API reference is due to Unity libraries)");
                    Debug.Log("GveBuild.OnPostprocessBuild added NSPhotoLibraryUsageDescription = " + ValueToString(plist.root.values[NSPhotoLibraryUsageDescription]));
                }

                // Write the modified file
                string plistPathNew = plistFilePath + ".new";
                plist.WriteToFile(plistPathNew);

                // Replace the original file. Note subsequent build steps modify the plist file further (e.g. currently facebook entries are added after this script runs)
                if (true)
                {
                    // Delete the old file
                    File.Delete(plistFilePath);
                }
                else
                {
                    // Keep the old file for diff while testing
                    string plistPathOld = plistFilePath + ".orig";
                    File.Move(plistFilePath, plistPathOld);
                }
                File.Move(plistPathNew, plistFilePath);
                Debug.Log("GveBuild.OnPostprocessBuild successfully updated " + plistFilePath);
            } catch (Exception e) {
                Debug.LogError("GveBuild.OnPostprocessBuild PList error " + e);
            }
            break;

        default:
            // nada
            break;
        }
    }
        static void AddNotificationExtension(PBXProject project, string projectPath)
        {
#if UNITY_2018_1_OR_NEWER
            const string extensionName = "/GetSocialNotificationExtension";
            if (!Directory.Exists(projectPath + extensionName))
            {
                Directory.CreateDirectory(projectPath + extensionName);
            }

            var           pluginDir = GetSocialSettings.GetPluginPath();
            PlistDocument notificationServicePlist = new PlistDocument();
            notificationServicePlist.ReadFromFile(pluginDir + "/Editor/iOS/Helpers/NotificationService/Info.plist");
            notificationServicePlist.root.SetString("CFBundleShortVersionString", PlayerSettings.bundleVersion);
            notificationServicePlist.root.SetString("CFBundleVersion", PlayerSettings.iOS.buildNumber);
            notificationServicePlist.WriteToFile(projectPath + "/GetSocialNotificationExtension/Info.plist");

            var extensionServiceSourceHeaderFile = pluginDir + "/Editor/iOS/Helpers/NotificationService/GetSocialNotificationService.h";
            var extensionServiceSourceImpFile    = pluginDir + "/Editor/iOS/Helpers/NotificationService/GetSocialNotificationService.m";
            var extensionServiceTargetHeaderFile = "GetSocialNotificationExtension/GetSocialNotificationService.h";
            var extensionServiceTargetImpFile    = "GetSocialNotificationExtension/GetSocialNotificationService.m";

            File.Copy(extensionServiceSourceHeaderFile, projectPath + "/" + extensionServiceTargetHeaderFile, true);
            File.Copy(extensionServiceSourceImpFile, projectPath + "/" + extensionServiceTargetImpFile, true);

            var mainTarget = project.TargetGuidByName(PBXProject.GetUnityTargetName());

            var appExtensionTarget = project.AddAppExtension(mainTarget, "GetSocialNotificationExtension", projectPath + "/GetSocialNotificationExtension/Info.plist");

            project.AddFileToBuild(appExtensionTarget, project.AddFile(extensionServiceTargetHeaderFile, extensionServiceTargetHeaderFile));
            project.AddFileToBuild(appExtensionTarget, project.AddFile(extensionServiceTargetImpFile, extensionServiceTargetImpFile));

            var frameworksPath =
                GetSocialSettings.GetPluginPath().Substring(GetSocialSettings.GetPluginPath().IndexOf("/") + 1);

            var relativeExtensionFrameworkPath = "Frameworks/" + frameworksPath + "/Plugins/iOS/GetSocialNotificationExtension.framework";

            project.AddFileToBuild(appExtensionTarget, project.FindFileGuidByProjectPath(relativeExtensionFrameworkPath));

            var deviceFamily = "";
            switch (PlayerSettings.iOS.targetDevice)
            {
            case iOSTargetDevice.iPhoneOnly:
                deviceFamily = "1";
                break;

            case iOSTargetDevice.iPadOnly:
                deviceFamily = "2";
                break;

            case iOSTargetDevice.iPhoneAndiPad:
                deviceFamily = "1,2";
                break;
            }


            project.SetBuildProperty(appExtensionTarget, "TARGETED_DEVICE_FAMILY", deviceFamily);
            if (double.Parse(PlayerSettings.iOS.targetOSVersionString) > 10)
            {
                project.SetBuildProperty(appExtensionTarget, "IPHONEOS_DEPLOYMENT_TARGET", PlayerSettings.iOS.targetOSVersionString.ToString());
            }
            else
            {
                project.SetBuildProperty(appExtensionTarget, "IPHONEOS_DEPLOYMENT_TARGET", "10.0");
            }

            project.SetBuildProperty(appExtensionTarget, "DEVELOPMENT_TEAM", PlayerSettings.iOS.appleDeveloperTeamID);
            project.SetBuildProperty(appExtensionTarget, "PRODUCT_BUNDLE_IDENTIFIER", GetSocialSettings.ExtensionBundleId);
            project.SetBuildProperty(appExtensionTarget, "CODE_SIGN_STYLE", PlayerSettings.iOS.appleEnableAutomaticSigning ?  "Automatic" : "Manual");
            if (!PlayerSettings.iOS.appleEnableAutomaticSigning)
            {
                if (GetSocialSettings.ExtensionProvisioningProfile.Length == 0)
                {
                    Debug.LogError("Notification Extension Provisioning Profile must be specified.");
                }
                else
                {
                    project.SetBuildProperty(appExtensionTarget, "PROVISIONING_PROFILE", GetSocialSettings.ExtensionProvisioningProfile);
                    project.SetBuildProperty(appExtensionTarget, "PROVISIONING_PROFILE_SPECIFIER", GetSocialSettings.ExtensionProvisioningProfile);
                }
            }
            project.AddFrameworkToProject(mainTarget, "UserNotifications.framework", false);
            AddExtensionEntitlements(projectPath, project, appExtensionTarget);
#endif
        }
示例#34
0
    public static void OnPostprocessBuild(BuildTarget buildTarget, string path)
    {
        if (buildTarget != BuildTarget.iOS)
        {
            Debug.LogWarning("Target is not IOS. XCodePostProcess will not run");
            return;
        }

        // Create a new project object from build target
        string     projPath = PBXProject.GetPBXProjectPath(path);
        PBXProject project  = new PBXProject();

        project.ReadFromString(File.ReadAllText(projPath));
        string target = project.TargetGuidByName("Unity-iPhone");

        project.AddFrameworkToProject(target, "libstdc++.6.0.9.tbd", false);
        project.AddFrameworkToProject(target, "libz.tbd", false);
        project.AddFrameworkToProject(target, "libsqlite3.tbd", false);
        project.AddFrameworkToProject(target, "StoreKit.framework", false);
        project.AddFrameworkToProject(target, "SystemConfiguration.framework", false);
        project.AddFrameworkToProject(target, "CoreTelephony.framework", false);
        project.AddFrameworkToProject(target, "QuartzCore.framework", false);
        project.AddFrameworkToProject(target, "Security.framework", false);

        // 对所有的编译配置设置选项
        project.SetBuildProperty(target, "ENABLE_BITCODE", "NO");
        project.AddBuildProperty(target, "OTHER_LDFLAGS", "-ObjC");

        // 保存工程
        project.WriteToFile(projPath);

        // 修改plist
        string        plistPath = path + "/Info.plist";
        PlistDocument plist     = new PlistDocument();

        plist.ReadFromString(File.ReadAllText(plistPath));

        //添加app信息到info.plist
        PlistElementDict rootDict = plist.root;
        PlistElementDict SDKDic   = rootDict.CreateDict("KSSDK");

        SDKDic.SetString("APPID", "100000022");                                          //CP填自己的appid
        SDKDic.SetString("APPKey", "c824619ea987f124ebbb75ef79d85196");                  //CP填自己的appkey


        //添加分享的信息
        PlistElementArray array = rootDict.CreateArray("CFBundleURLTypes");

/*
 *              // 微信分享信息
 *              PlistElementDict dictWechat = array.AddDict();
 *              dictWechat.SetString("CFBundleURLName", "weixin");
 *              PlistElementArray arrayWechat = dictWechat.CreateArray("CFBundleURLSchemes");
 *              arrayWechat.AddString("wx21662a277bfda3a2");                        //CP填自己的wxappid
 *
 *              // QQ分享信息
 *              PlistElementDict dictQQ = array.AddDict ();
 *              dictQQ.SetString ("CFBundleURLName", "tecnet");
 *              PlistElementArray arrayQQ = dictQQ.CreateArray("CFBundleURLSchemes");
 *              arrayQQ.AddString ("tecent222222");									//CP填自己的QQ id
 *
 *              // 微博分享
 *              PlistElementDict dictWeibo = array.AddDict();
 *              dictWeibo.SetString("CFBundleURLName","weibo");
 *              PlistElementArray arrayWeibo = dictWeibo.CreateArray("CFBundleURLSchemes");
 *              arrayWeibo.AddString("wb2980459460");								//CP填写自己的微博id
 *
 *              //银联信息
 *              PlistElementDict dictUP = array.AddDict();
 *              PlistElementArray arrayUP = dictUP.CreateArray ("CFBundleURLSchemes");
 *              arrayUP.AddString("KSUPPay");										//此值可以为任意值,但必须唯一
 */

        array = rootDict.CreateArray("LSApplicationQueriesSchemes");
        array.AddString("weixin");
        array.AddString("wechat");
        array.AddString("weibosdk2.5");
        array.AddString("weibosdk");
        array.AddString("sinaweibo");
        array.AddString("sinaweibohd");
        array.AddString("mqq");
        array.AddString("mqqapi");
        array.AddString("mqqopensdkapiV2");
        array.AddString("mqqbrowser");
        // 下面字段为自有支付相关
        array.AddString("uppayx1");
        array.AddString("uppayx2");
        array.AddString("uppayx3");
        array.AddString("uppaywallet");
        array.AddString("uppaysdk");

        // 语音所需要的声明
        rootDict.SetString("NSMicrophoneUsageDescription", "通过麦克风和其他玩家语音聊天");

        // 相册所需权限
        rootDict.SetString("NSPhotoLibraryAddUsageDescription", "将账号密码保存至相册中");
        rootDict.SetString("Privacy - Photo Library Usage Description", "将账号密码保存至相册中");

        //添加允许http访问
        PlistElementDict dict3 = rootDict.CreateDict("NSAppTransportSecurity");

        dict3.SetBoolean("NSAllowsArbitraryLoads", true);

        // save info.plist
        plist.WriteToFile(plistPath);

        EditUnityAppController(path);

        Debug.Log("Xcode修改完毕");
    }
示例#35
0
        public void AddAnimationsWithFile(string plist)
        {
            Debug.Assert(!string.IsNullOrEmpty(plist), "Invalid texture file name");

            string path = CCFileUtils.FullPathFromRelativePath(plist);

            PlistDocument document = null;
            try
            {
                document = CCApplication.SharedApplication.Content.Load<PlistDocument>(path);
            }
            catch (System.Exception)
            {
                string xml = CCContent.LoadContentFile(path);
                if (xml != null)
                {
                    document = new PlistDocument(xml);
                }
            }
            if (document == null)
            {
                throw (new Microsoft.Xna.Framework.Content.ContentLoadException("Failed to load the particle definition file from " + path));
            }

            PlistDictionary dict = document.Root.AsDictionary;

            Debug.Assert(dict != null, "CCAnimationCache: File could not be found");

            AddAnimationsWithDictionary(dict);
        }
示例#36
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="pszPlist"></param>
        /// <returns>The scope parameter derived from the pszPlist parameter.</returns>
        public string AddSpriteFramesWithFile(string pszPlist)
        {
            string path = CCFileUtils.FullPathFromRelativePath(pszPlist);
            //Dictionary<string, Object> dict = CCFileUtils.dictionaryWithContentsOfFile(pszPath);
            PlistDocument document = null;
            try
            {
                document = CCApplication.SharedApplication.Content.Load<PlistDocument>(path);
            }
            catch (System.Exception)
            {
                string xml = CCContent.LoadContentFile(path);
                if (xml != null)
                {
                    document = new PlistDocument(xml);
                }
            }
            if (document == null)
            {
                throw (new Microsoft.Xna.Framework.Content.ContentLoadException("Failed to load the particle definition file from " + path));
            }

            PlistDictionary dict = document.Root.AsDictionary;
            string texturePath = "";
            PlistDictionary metadataDict = dict.ContainsKey("metadata") ? dict["metadata"].AsDictionary : null;

            string framePrefix = string.Empty;
            if (metadataDict != null)
            {
                // try to read  texture file name from meta data
                if (metadataDict.ContainsKey("textureFileName"))
                {
                    texturePath = metadataDict["textureFileName"].AsString;
                    framePrefix = ExtractPrefix(texturePath);
                }
            }

            if (!string.IsNullOrEmpty(texturePath))
            {
                // build texture path relative to plist file
                texturePath = CCFileUtils.FullPathFromRelativeFile(texturePath, path);
            }
            else
            {
                // build texture path by replacing file extension
                texturePath = path;

                // remove .xxx
                texturePath = CCFileUtils.RemoveExtension(texturePath);

                CCLog.Log("cocos2d: CCSpriteFrameCache: Trying to use file {0} as texture", texturePath);
            }

            CCTexture2D pTexture = CCTextureCache.SharedTextureCache.AddImage(texturePath);

            if (pTexture != null)
            {
                AddSpriteFramesWithDictionary(dict, pTexture, framePrefix);
            }
            else
            {
                CCLog.Log("cocos2d: CCSpriteFrameCache: Couldn't load texture");
            }
            return (framePrefix);
        }
示例#37
0
    private static void UpdatePlist(string pathToBuiltProject, string clientId)
    {
        if (pathToBuiltProject != null && pathToBuiltProject.Length > 0)
        {
            string plistFilePath = Path.Combine(pathToBuiltProject, "Info.plist");

            if (File.Exists(plistFilePath))
            {
                PlistDocument plistDocument = new PlistDocument();

                plistDocument.ReadFromFile(plistFilePath);

                // Add url schemes

                PlistElement urlTypesElement = plistDocument.root["CFBundleURLTypes"];

                if (urlTypesElement == null)
                {
                    plistDocument.root["CFBundleURLTypes"] = new PlistElementArray();
                }

                PlistElementArray urlTypes = plistDocument.root["CFBundleURLTypes"].AsArray();

                bool updated = false;

                if (urlTypes != null)
                {
                    PlistElementDict dict = urlTypes.AddDict();

                    PlistElementArray array = dict.CreateArray("CFBundleURLSchemes");

                    array.AddString("us" + clientId);
                    array.AddString("ep" + clientId);

                    updated = true;
                }

                // Add allow arbitrary loads

                PlistElement appTransportSecurityElement = plistDocument.root["NSAppTransportSecurity"];

                if (appTransportSecurityElement == null)
                {
                    plistDocument.root["NSAppTransportSecurity"] = new PlistElementDict();
                }

                PlistElementDict appTransportSecurityElementDict = plistDocument.root["NSAppTransportSecurity"].AsDict();

                if (appTransportSecurityElementDict != null)
                {
                    appTransportSecurityElementDict["NSAllowsArbitraryLoads"] = new PlistElementBoolean(true);
                }

                // Add camera usage description for iOS 10

                PlistElement cameraUsageDescriptionElement = plistDocument.root["NSCameraUsageDescription"];

                if (cameraUsageDescriptionElement == null)
                {
                    plistDocument.root["NSCameraUsageDescription"] = new PlistElementString("HeyPlay requires access to the camera");
                }

                // Add microphone usage description for iOS 10

                PlistElement microphoneUsageDescriptionElement = plistDocument.root["NSMicrophoneUsageDescription"];

                if (microphoneUsageDescriptionElement == null)
                {
                    plistDocument.root["NSMicrophoneUsageDescription"] = new PlistElementString("HeyPlay requires access to the microphone");
                }

                // Add photo library usage description for iOS 10

                PlistElement photoLibraryUsageDescriptionElement = plistDocument.root["NSPhotoLibraryUsageDescription"];

                if (photoLibraryUsageDescriptionElement == null)
                {
                    plistDocument.root["NSPhotoLibraryUsageDescription"] = new PlistElementString("HeyPlay requires access to the photo library");
                }

                // Add contact usage description for iOS 10

                PlistElement contactUsageDescriptionElement = plistDocument.root["NSContactsUsageDescription"];

                if (contactUsageDescriptionElement == null)
                {
                    plistDocument.root["NSContactsUsageDescription"] = new PlistElementString("HeyPlay requires access to the contacts");
                }

                if (updated)
                {
                    plistDocument.WriteToFile(plistFilePath);
                }
            }
        }
    }
示例#38
0
        public void RemoveSpriteFramesFromFile(string plist)
        {
            //string path = CCFileUtils.fullPathFromRelativePath(plist);
            //Dictionary<string, object> dict = CCFileUtils.dictionaryWithContentsOfFile(path);
            PlistDocument document = null;
            try
            {
                document = CCApplication.SharedApplication.Content.Load<PlistDocument>(plist);
            }
            catch (System.Exception)
            {
                string xml = CCContent.LoadContentFile(plist);
                if (xml != null)
                {
                    document = new PlistDocument(xml);
                }
            }
            if (document == null)
            {
                throw (new Microsoft.Xna.Framework.Content.ContentLoadException("Failed to load the particle definition file from " + plist));
            }

            PlistDictionary dict = document.Root.AsDictionary;

            RemoveSpriteFramesFromDictionary(dict);
        }
示例#39
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="pszPlist"></param>
        /// <param name="pobTexture"></param>
        /// <param name="framePrefix"></param>
        /// <returns>The framePrefix parameter</returns>
        public string AddSpriteFramesWithFile(string pszPlist, CCTexture2D pobTexture, string framePrefix)
        {
            //string pszPath = CCFileUtils.fullPathFromRelativePath(pszPlist);
            //Dictionary<string, Object> dict = CCFileUtils.dictionaryWithContentsOfFile(pszPath);
            PlistDocument document = null;
            try
            {
                document = CCApplication.SharedApplication.Content.Load<PlistDocument>(pszPlist);
            }
            catch (System.Exception)
            {
                string xml = CCContent.LoadContentFile(pszPlist);
                if (xml != null)
                {
                    document = new PlistDocument(xml);
                }
            }
            if (document == null)
            {
                throw (new Microsoft.Xna.Framework.Content.ContentLoadException("Failed to load the particle definition file from " + pszPlist));
            }

            PlistDictionary dict = document.Root.AsDictionary;

            AddSpriteFramesWithDictionary(dict, pobTexture, framePrefix);
            return (framePrefix);
        }
示例#40
0
    public static void OnPostprocessBuild(BuildTarget BuildTarget, string path)
    {
        Debug.Log("Build path:" + path);
        if (BuildTarget == BuildTarget.iOS)
        {
            Debug.Log("BuildTarget == BuildTarget.iOS");
            string projPath = PBXProject.GetPBXProjectPath(path);
            Debug.Log("PBXProject path:" + projPath);
            PBXProject proj = new PBXProject();
            proj.ReadFromString(File.ReadAllText(projPath));

            // 获取当前项目名字
            string target = proj.TargetGuidByName(PBXProject.GetUnityTargetName());
            Debug.Log("target path:" + target);
            // 对所有的编译配置设置选项
            proj.SetBuildProperty(target, "ENABLE_BITCODE", "NO");

            // 添加依赖库
            // weixin sdk
            //proj.AddFrameworkToProject (target, "SystemConfiguration.framework", false);
            proj.AddFrameworkToProject(target, "libz.tbd", false);
            proj.AddFrameworkToProject(target, "libsqlite3.0.tbd", false);
            proj.AddFrameworkToProject(target, "libc++.tbd", false);
            proj.AddFrameworkToProject(target, "Security.framework", false);
            //proj.AddFrameworkToProject (target, "CoreTelephony.framework", false);
            proj.AddFrameworkToProject(target, "CFNetwork.framework", false);
            proj.AddFrameworkToProject(target, "MobileCoreServices.framework", false);
            // GVoice sdk
            proj.AddFrameworkToProject(target, "SystemConfiguration.framework", false);
            proj.AddFrameworkToProject(target, "CoreTelephony.framework", false);
            proj.AddFrameworkToProject(target, "AudioToolbox.framework", false);
            proj.AddFrameworkToProject(target, "CoreAudio.framework", false);
            proj.AddFrameworkToProject(target, "AVFoundation.framework", false);
            proj.AddFrameworkToProject(target, "libstdc++.6.0.9.tbd", false);
            // UnityAppController.mm add -fno-objc-arc flag
            string file  = proj.FindFileGuidByProjectPath("Classes/UnityAppController.mm");
            var    flags = proj.GetCompileFlagsForFile(target, file);
            flags.Add("-fno-objc-arc");
            proj.SetCompileFlagsForFile(target, file, flags);

            proj.AddBuildProperty(
                target, "HEADER_SEARCH_PATHS", "$(SRCROOT)/Libraries/Plugins/iOS"
                );
            proj.AddBuildProperty(target, "OTHER_LDFLAGS", "-ObjC");
            proj.AddBuildProperty(target, "OTHER_LDFLAGS", "-force_load $(SRCROOT)/Libraries/Plugins/iOS/libWeChatSDK.a");
            proj.SetBuildProperty(target, "ENABLE_BITCODE", "NO");
            proj.SetBuildProperty(target, "GCC_ENABLE_OBJC_EXCEPTIONS", "YES");
            // 保存工程
            proj.WriteToFile(projPath);

            // 修改plist
            string        plistPath = path + "/Info.plist";
            PlistDocument plist     = new PlistDocument();
            plist.ReadFromString(File.ReadAllText(plistPath));
            PlistElementDict rootDict = plist.root;
            // weixin 相关
            {
                var arr = rootDict.CreateArray("CFBundleURLTypes");
                {
                    var dict = arr.AddDict();
                    dict.SetString("CFBundleTypeRole", "Editor");
                    dict.SetString("CFBundleURLName", "weixin");
                    var arr1 = dict.CreateArray("CFBundleURLSchemes");
                    arr1.AddString("wxafd936830b3cf60f");
                }
            }
            {
                var arr = rootDict.CreateArray("LSApplicationQueriesSchemes");
                arr.AddString("wechat");
                arr.AddString("weixin");
            }
            {
                var arr = rootDict.CreateArray("UIBackgroundModes");
                arr.AddString("remote-notification");
            }
            rootDict.SetString("NSMicrophoneUsageDescription", "语音需要打开麦克风");
            // 保存plist
            plist.WriteToFile(plistPath);

            // UnityAppController.mm代码修改
            EditorCode(path);
        }
    }
        public string AddSpriteFramesWithFile(Stream plist, CCTexture2D pobTexture, string framePrefix)
        {
            PlistDocument document = new PlistDocument();
            try
            {
                document.LoadFromXmlFile(plist);
            }
            catch (Exception)
            {
                throw (new Microsoft.Xna.Framework.Content.ContentLoadException("Failed to load the particle definition file from stream"));
            }

            PlistDictionary dict = document.Root.AsDictionary;

            AddSpriteFramesWithDictionary(dict, pobTexture, framePrefix);
            return (framePrefix);
        }
        static void ModifyPlist(string path)
        {
            // Info.plist
            string        plistPath = path + "/Info.plist";
            PlistDocument plist     = new PlistDocument();

            plist.ReadFromString(File.ReadAllText(path: plistPath));

            // ROOT
            PlistElementDict  rootDict = plist.root;
            PlistElementArray urlTypes = rootDict.CreateArray("CFBundleURLTypes");

            // Add URLScheme For Wechat
            PlistElementDict wxUrl = urlTypes.AddDict();

            wxUrl.SetString("CFBundleTypeRole", "Editor");
            wxUrl.SetString("CFBundleURLName", "weixin");
            wxUrl.SetString("CFBundleURLSchemes", val: Config.wechatAppId);
            PlistElementArray wxUrlScheme = wxUrl.CreateArray("CFBundleURLSchemes");

            wxUrlScheme.AddString(val: Config.wechatAppId);

            // Add URLScheme For jiguang
            PlistElementDict jgUrl = urlTypes.AddDict();

            jgUrl.SetString("CFBundleTypeRole", "Editor");
            jgUrl.SetString("CFBundleURLName", "jiguang");
            jgUrl.SetString("CFBundleURLSchemes", val: "jiguang-" + Config.jgAppKey);
            PlistElementArray jgUrlScheme = jgUrl.CreateArray("CFBundleURLSchemes");

            jgUrlScheme.AddString(val: "jiguang-" + Config.jgAppKey);

            // Add URLScheme For unityconnect
            PlistElementDict appUrl = urlTypes.AddDict();

            appUrl.SetString("CFBundleTypeRole", "Editor");
            appUrl.SetString("CFBundleURLName", "");
            appUrl.SetString("CFBundleURLSchemes", val: "unityconnect");
            PlistElementArray appUrlScheme = appUrl.CreateArray("CFBundleURLSchemes");

            appUrlScheme.AddString(val: "unityconnect");

            // 白名单 for wechat
            PlistElementArray queriesSchemes = rootDict.CreateArray("LSApplicationQueriesSchemes");

            queriesSchemes.AddString("wechat");
            queriesSchemes.AddString("weixin");
            queriesSchemes.AddString(val: Config.wechatAppId);

            // HTTP 设置
            const string     atsKey  = "NSAppTransportSecurity";
            PlistElementDict dictTmp = rootDict.CreateDict(key: atsKey);

            dictTmp.SetBoolean("NSAllowsArbitraryLoads", true);

            PlistElementArray backModes = rootDict.CreateArray("UIBackgroundModes");

            backModes.AddString("remote-notification");

            // 出口合规信息
            rootDict.SetBoolean("ITSAppUsesNonExemptEncryption", false);

            rootDict.SetString("NSCameraUsageDescription", "App需要您的同意,才能访问相机");
            rootDict.SetString("NSPhotoLibraryUsageDescription", "App需要您的同意,才能访问相册");
            rootDict.SetString("NSMicrophoneUsageDescription", "App需要您的同意,才能访问麦克风");
            // remove exit on suspend if it exists.
            string exitsOnSuspendKey = "UIApplicationExitsOnSuspend";

            if (rootDict.values.ContainsKey(exitsOnSuspendKey))
            {
                rootDict.values.Remove(exitsOnSuspendKey);
            }

            // 写入
            File.WriteAllText(plistPath, plist.WriteToString());
        }