示例#1
0
        public bool ApplyChanges(XcodeChangeFile changes)
        {
            if (changes == null)
            {
                Debug.LogError("EgoXproject: Must have a valid change file");
                return(false);
            }

            if (_pbxproj == null)
            {
                Debug.LogError("EgoXproject: Must load an Xcode project first");
                return(false);
            }

            _platform = changes.Platform;

            if (!ApplyPBXProjChanges(changes))
            {
                Debug.LogError("EgoXproject: Unable to apply changes and save Xcode project file - " + _pbxproj.ErrorMessage + ". Path: " + _pxbProjPath);
                return(false);
            }

            if (!ApplyInfoPlistChanges(changes.InfoPlistChanges))
            {
                return(false);
            }

            if (!ApplyCapabilityChanges(changes.Capabilities))
            {
                return(false);
            }

            return(true);
        }
示例#2
0
        void UpgradeFolders(PList plist, XcodeChangeFile changeFile)
        {
            var filesFolders = plist.Root.DictionaryValue("FilesAndFolders");

            if (filesFolders == null)
            {
                return;
            }

            var folders = filesFolders.ArrayValue("Folders");

            if (folders == null)
            {
                return;
            }

            for (int ii = 0; ii < folders.Count; ii++)
            {
                var folderDic = folders.DictionaryValue(ii);

                if (folderDic == null)
                {
                    continue;
                }

                var entry = FileAndFolderEntryFactory.CreateFromObsolete(folderDic);

                if (entry == null)
                {
                    continue;
                }

                changeFile.FilesAndFolders.Upgrader_AddEntry(entry);
            }
        }
示例#3
0
        public XcodeChangeFile CreateChangeFile(BuildPlatform platform, string filePath)
        {
            _creationOrDeletionInProgress = true;

            if (File.Exists(filePath))
            {
                File.Delete(filePath);
            }

            var changeFile = new XcodeChangeFile();

            changeFile.Platform = platform;
            changeFile.Save(filePath);

            if (platform == BuildPlatform.tvOS)
            {
                _tvosChangeFiles.Add(filePath);
            }
            else
            {
                _iosChangeFiles.Add(filePath);
            }

            RefreshConfigurations();
            LastSaveDirectory = Path.GetDirectoryName(filePath);
            AssetDatabase.ImportAsset(filePath);
            _creationOrDeletionInProgress = false;
            return(changeFile);
        }
示例#4
0
        void UpgradeCustomFrameworks(PList plist, XcodeChangeFile changeFile)
        {
            var frameworks = plist.Root.DictionaryValue("Frameworks");

            if (frameworks == null)
            {
                return;
            }

            var customFrameworks = frameworks.ArrayValue("Custom");

            if (customFrameworks == null)
            {
                return;
            }

            for (int ii = 0; ii < customFrameworks.Count; ii++)
            {
                var customFrameworkDic = customFrameworks.DictionaryValue(ii);

                if (customFrameworkDic == null)
                {
                    continue;
                }

                var entry = FileAndFolderEntryFactory.CreateFromObsolete(customFrameworkDic);

                if (entry == null)
                {
                    continue;
                }

                changeFile.FilesAndFolders.Upgrader_AddEntry(entry);
            }
        }
示例#5
0
 bool ApplyPBXProjChanges(XcodeChangeFile changes)
 {
     AddFrameworks(changes.Frameworks);
     AddFilesAndFolders(changes.FilesAndFolders);
     AddBuildSettings(changes.BuildSettings);
     AddScripts(changes.Scripts);
     ApplySigningChanges(changes.Signing);
     return(_pbxproj.Save());
 }
示例#6
0
        public static XcodeChangeFile Load(string pathToFile)
        {
            var changeFile = new XcodeChangeFile();

            if (changeFile.LoadFile(pathToFile))
            {
                return(changeFile);
            }

            return(null);
        }
示例#7
0
        public void Merge(XcodeChangeFile other)
        {
            if (Platform != other.Platform)
            {
                Debug.LogError("Cannot merge change files. Platforms do not match");
                return;
            }

            MergePListEntries(InfoPlistChanges, other.InfoPlistChanges);
            Frameworks.Merge(other.Frameworks);
            FilesAndFolders.Merge(other.FilesAndFolders);
            BuildSettings.Merge(other.BuildSettings);
            Scripts.Merge(other.Scripts);
            Signing.Merge(other.Signing);
            Capabilities.Merge(other.Capabilities);
        }
示例#8
0
        void FindChangeFiles()
        {
            _iosChangeFiles.Clear();
            _tvosChangeFiles.Clear();
            _macosChangeFiles.Clear();
            string[] allPListPaths = Directory.GetFiles(Application.dataPath, "*" + XcodeChangeFile.Extension, SearchOption.AllDirectories);

            if (allPListPaths.Length > 0)
            {
                foreach (var path in allPListPaths)
                {
                    string fileName = Path.GetFileName(path);

                    if (string.IsNullOrEmpty(fileName) || fileName.StartsWith(".", StringComparison.InvariantCultureIgnoreCase))
                    {
                        continue;
                    }

                    //load and validate the files
                    var tmp = XcodeChangeFile.Load(path);

                    if (tmp != null)
                    {
                        string relativePath = ProjectUtil.MakePathRelativeToProject(path);

                        if (tmp.Platform == BuildPlatform.tvOS)
                        {
                            _tvosChangeFiles.Add(relativePath);
                        }
                        else if (tmp.Platform == BuildPlatform.MacOS)
                        {
                            _macosChangeFiles.Add(relativePath);
                        }
                        else
                        {
                            _iosChangeFiles.Add(relativePath);
                        }
                    }
                    else
                    {
                        Debug.LogError("EgoXproject: Failed to load " + path);
                    }
                }
            }
        }
示例#9
0
        public XcodeChangeFile MergedChanges(BuildPlatform platform)
        {
            var configuration = _configurations.Configuration(platform);

            string[] changeFiles;

            //TODO this is a reason for the Platform Configuration to hold all the change files.
            if (configuration.ActiveConfiguration == PlatformConfiguration.DEFAULT_CONFIG_NAME)
            {
                changeFiles = ChangeFiles(platform);
            }
            else
            {
                changeFiles = configuration.ChangeFilesInConfiguration(configuration.ActiveConfiguration);
            }

            XcodeChangeFile merged = new XcodeChangeFile();

            merged.Platform = platform;

            if (changeFiles == null || changeFiles.Length == 0)
            {
                return(merged);
            }

            foreach (var c in changeFiles)
            {
                XcodeChangeFile cf = XcodeChangeFile.Load(c);

                if (cf != null)
                {
                    merged.Merge(cf);
                }
            }

            return(merged);
        }
示例#10
0
        void UpgradeChangeFile(string fileName)
        {
            var plist = new PList();

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

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

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

            BackupFile(fileName);
            var changeFile = XcodeChangeFile.Load(fileName);

            if (changeFile == null)
            {
                return;
            }

            changeFile.Platform = BuildPlatform.iOS;
            //TODO handle upgrade failure
            //move custom frameworks to files and folder section
            UpgradeCustomFrameworks(plist, changeFile);
            //move files and folders to a single entries list
            UpgradeFiles(plist, changeFile);
            UpgradeFolders(plist, changeFile);
            changeFile.Save();
        }