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); }
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); } }
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); }
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); } }
bool ApplyPBXProjChanges(XcodeChangeFile changes) { AddFrameworks(changes.Frameworks); AddFilesAndFolders(changes.FilesAndFolders); AddBuildSettings(changes.BuildSettings); AddScripts(changes.Scripts); ApplySigningChanges(changes.Signing); return(_pbxproj.Save()); }
public static XcodeChangeFile Load(string pathToFile) { var changeFile = new XcodeChangeFile(); if (changeFile.LoadFile(pathToFile)) { return(changeFile); } return(null); }
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); }
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); } } } }
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); }
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(); }