コード例 #1
0
        bool ModifyEntitlementsFile(string pathToEntitlementsFile, PListDictionary changes, bool keepEmpty = false)
        {
            PList entitlementsFile = new PList();

            if (!File.Exists(pathToEntitlementsFile))
            {
                if (!entitlementsFile.Save(pathToEntitlementsFile, true))
                {
                    Debug.LogError("EgoXproject: Failed to create entitlements file: " + pathToEntitlementsFile);
                    return(false);
                }
            }

            if (entitlementsFile.Load(pathToEntitlementsFile))
            {
                MergeDictionaries(entitlementsFile.Root, changes, keepEmpty, false);

                if (entitlementsFile.Save())
                {
                    return(true);
                }
                else
                {
                    Debug.LogError("EgoXproject: Failed to save entitlements file: " + pathToEntitlementsFile);
                    return(false);
                }
            }
            else
            {
                Debug.LogError("EgoXproject: Failed to open entitlements file: " + pathToEntitlementsFile);
                return(false);
            }
        }
コード例 #2
0
        public bool Save()
        {
            if (string.IsNullOrEmpty(SavePath))
            {
                return(false);
            }

            PList plist = new PList();

            plist.Root.Add(TYPE_KEY, TYPE_VALUE);
            plist.Root.Add(VERSION_KEY, VERSION);
            plist.Root.Add(BUILD_PLATFORM_KEY, Platform.ToString());
            plist.Root.Add(INFO_PLIST_KEY, InfoPlistChanges);
            plist.Root.Add(APP_CONFIG_KEY, AppConfig);
            plist.Root.Add(APP_CONFIG_ENABLED_KEY, AppConfigEnabled);
            plist.Root.Add(MANUAL_ENTITLEMENTS, ManualEntitlements);
            plist.Root.Add(FRAMEWORKS_KEY, Frameworks.Serialize());
            plist.Root.Add(FILES_AND_FOLDERS_KEY, FilesAndFolders.Serialize());
            plist.Root.Add(BUILD_SETTINGS_KEY, BuildSettings.Serialize());
            plist.Root.Add(SIGNING_KEY, Signing.Serialize());
            plist.Root.Add(SCRIPTS_KEY, Scripts.Serialize());


            plist.Root.Add(CAPABILITIES_KEY, Capabilities.Serialize());
            bool saved = plist.Save(SavePath, true);

            if (saved)
            {
                IsDirty = false;
            }

            return(saved);
        }
コード例 #3
0
        public void PrepareBundlePlugins(BuildTarget target, string pathToXcodeProject)
        {
            if (target == BuildTarget.StandaloneOSX)
            {
                // Loop through Xcode project to find all .bundle plugins:
                foreach (string filePath in Directory.GetDirectories(pathToXcodeProject, "*.bundle", SearchOption.AllDirectories))
                {
                    // This should be the path to the main Info.plist file of the plugin
                    string plistPath = filePath + "/Contents/Info.plist";

                    // This bundle does not have a Info.plist file, that's strange - let's stop now to make sure we don't break anything
                    if (!File.Exists(plistPath))
                    {
                        continue;
                    }

                    // Multiple Info.plist files cause problems, and the Prime31 iCloud Mac plugin has these, so let's remove them
                    string[] allInfoPlists = Directory.GetFiles(filePath, "Info.plist", SearchOption.AllDirectories);
                    if (allInfoPlists.Length > 1)
                    {
                        for (int i = 0; i < allInfoPlists.Length; i++)
                        {
                            // Delete any Info.plist file that's not the main one
                            if (allInfoPlists[i] != plistPath)
                            {
                                File.Delete(allInfoPlists[i]);
                            }
                        }
                    }

                    // Delete all metafiles inside the bundle. Not necessary after Unity 2019, but let's check to be sure
                    string[] allMetaFiles = Directory.GetFiles(filePath, "*.meta", SearchOption.AllDirectories);
                    for (int i = 0; i < allMetaFiles.Length; i++)
                    {
                        File.Delete(allInfoPlists[i]);
                    }

                    PList plist = XcodeEditor.LoadResourcePlist(plistPath);

                    // This is the filename of the plugin, minus extension:
                    string bundleName = Path.GetFileName(filePath).Replace(".bundle", "");

                    // Set the CFBundleIdentifier to be com.company.product.bundleName
                    if (!plist.Root.ContainsKey("CFBundleIdentifier"))
                    {
                        plist.Root.Add("", Application.identifier + "." + bundleName);
                    }
                    else
                    {
                        plist.Root["CFBundleIdentifier"] = new PListString(Application.identifier + "." + bundleName);
                    }

                    // Save the Plist file
                    plist.Save(plistPath, true);

                    // Let's remove any codesigning from this plugin, so only the main app code sign is being used
                    ExecuteProcessTerminal(string.Format("codesign --remove-signature {0}", filePath));
                }
            }
        }
コード例 #4
0
        void UpgradeSettingsFile(string fileName)
        {
            var plist = new PList();

            if (!plist.Load(fileName))
            {
                return;
            }

            if (plist.Root.StringValue("Type") != "EgoXproject Settings")
            {
                return;
            }

            if (plist.Root.IntValue("Version") != 1 && plist.Root.IntValue("Version") != 2)
            {
                return;
            }

            var dirName        = Path.GetDirectoryName(fileName);
            var configurations = new XcodeConfigurations(dirName);
            var platformConfig = configurations.Configuration(BuildPlatform.iOS);
            var configs        = plist.Root.DictionaryValue("Configurations");

            if (configs != null)
            {
                foreach (var kvp in configs)
                {
                    var entries = kvp.Value as PListArray;

                    if (entries == null || entries.Count <= 0)
                    {
                        platformConfig.AddConfiguration(kvp.Key);
                        continue;
                    }

                    for (int ii = 0; ii < entries.Count; ++ii)
                    {
                        platformConfig.AddChangeFileToConfiguration(entries.StringValue(ii), kvp.Key);
                    }
                }
            }

            var active = plist.Root.StringValue("ActiveConfiguration");

            if (!string.IsNullOrEmpty(active))
            {
                platformConfig.ActiveConfiguration = active;
            }

            configurations.Save();
            plist.Root.Remove("Configurations");
            plist.Root.Remove("ActiveConfiguration");
            plist.Save();
            string oldPath = ProjectUtil.MakePathRelativeToProject(plist.SavePath);
            string newPath = ProjectUtil.MakePathRelativeToProject(Path.Combine(Path.GetDirectoryName(oldPath), "egoxproject.settings"));

            AssetDatabase.MoveAsset(oldPath, newPath);
        }
コード例 #5
0
        bool ModifyInfoPlist(string pathToInfoPlist, PListDictionary changes, bool forceReplace)
        {
            PList infoPlist = new PList();

            if (infoPlist.Load(pathToInfoPlist))
            {
                MergeDictionaries(infoPlist.Root, changes, false, forceReplace);
                return(infoPlist.Save());
            }
            else
            {
                Debug.LogError("EgoXproject: Failed to open Info.plist file: " + pathToInfoPlist);
                return(false);
            }
        }
コード例 #6
0
ファイル: XcodeSettings.cs プロジェクト: sakitume/EgoXproject
        public void Save()
        {
            var plist = new PList();

            plist.Root.Add(TYPE_KEY, TYPE_VALUE);
            plist.Root.Add(VERSION_KEY, VERSION);
            plist.Root.Add(AUTORUN_KEY, _autoRun);
            plist.Root.Add(IGNORE_KEY, new PListArray(IgnoredFiles.CustomList));
            bool assetImport = !File.Exists(_savePath);

            if (plist.Save(_savePath, true))
            {
                IsDirty = false;

                if (assetImport)
                {
                    AssetDatabase.ImportAsset(ProjectUtil.MakePathRelativeToProject(_savePath));
                }
            }
        }
コード例 #7
0
        public void Save()
        {
            var plist = new PList();

            plist.Root.Add(TYPE_KEY, TYPE_VALUE);
            plist.Root.Add(VERSION_KEY, VERSION);
            plist.Root.Add(BuildPlatform.iOS.ToString(), _iosConfigs.Serialize());
            plist.Root.Add(BuildPlatform.tvOS.ToString(), _tvosConfigs.Serialize());
            bool assetImport = !File.Exists(_savePath);

            if (plist.Save(_savePath, true))
            {
                IsDirty = false;

                if (assetImport)
                {
                    AssetDatabase.ImportAsset(ProjectUtil.MakePathRelativeToProject(_savePath));
                }
            }
        }