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); } }
void Load() { if (!File.Exists(_savePath)) { _savePath = FindFileLocation(); } if (File.Exists(_savePath)) { PList p = new PList(); if (p.Load(_savePath)) { if (Validate(p)) { ParseFile(p); return; } } //fall through to fail mode var backupPath = _savePath + ".corrupted-" + System.DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss"); Debug.LogWarning("EgoXproject: Corrupted configuration file found. Recreating."); Debug.LogWarning("EgoXproject: Corrupted file backed up to " + backupPath); AssetDatabase.MoveAsset(_savePath, backupPath); } }
void Load() { if (!File.Exists(_savePath)) { _savePath = FindSettingsFileLocation(); } if (File.Exists(_savePath)) { PList p = new PList(); if (p.Load(_savePath)) { if (Validate(p)) { ParseSettingsFile(p); return; } } //fall through to fail mode var backupPath = _savePath + ".corrupted-" + System.DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss"); Debug.LogWarning("EgoXproject: Corrupted settings found. Recreating."); Debug.LogWarning("EgoXproject: Corrupted file backed up to " + backupPath); File.Move(_savePath, backupPath); } //fill in empty values CreateDefaultSettings(); }
bool LoadFile(string pathToFile) { if (!File.Exists(pathToFile)) { Debug.LogError("EgoXproject: Change file does not exist: " + pathToFile); return(false); } SavePath = pathToFile; PList p = new PList(); if (!p.Load(SavePath)) { return(false); } if (!Validate(p)) { return(false); } //set the platform. if non specified will default to ios BuildPlatform platform; if (p.Root.EnumValue(BUILD_PLATFORM_KEY, out platform)) { Platform = platform; } else { Platform = BuildPlatform.iOS; } //reset everything Frameworks.Clear(); FilesAndFolders.Clear(); BuildSettings.Clear(); Scripts.Clear(); Signing.Clear(); Capabilities.Clear(); //load everything InfoPlistChanges = p.Root.DictionaryValue(INFO_PLIST_KEY).Copy() as PListDictionary; AppConfig = p.Root.DictionaryValue(APP_CONFIG_KEY) != null?p.Root.DictionaryValue(APP_CONFIG_KEY).Copy() as PListDictionary : new PListDictionary(); AppConfigEnabled = p.Root.ArrayValue(APP_CONFIG_ENABLED_KEY) != null?p.Root.ArrayValue(APP_CONFIG_ENABLED_KEY).Copy() as PListArray : new PListArray(); ManualEntitlements = p.Root.DictionaryValue(MANUAL_ENTITLEMENTS) != null?p.Root.DictionaryValue(MANUAL_ENTITLEMENTS).Copy() as PListDictionary : new PListDictionary(); LoadFrameworks(p.Root.DictionaryValue(FRAMEWORKS_KEY)); LoadFilesAndFolders(p.Root.DictionaryValue(FILES_AND_FOLDERS_KEY)); LoadScripts(p.Root.ArrayValue(SCRIPTS_KEY)); LoadBuildSettings(p.Root.ArrayValue(BUILD_SETTINGS_KEY)); LoadSigning(p.Root.DictionaryValue(SIGNING_KEY)); LoadCapabilities(p.Root.DictionaryValue(CAPABILITIES_KEY)); IsDirty = false; return(true); }
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); }
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); } }
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(); }