Exemple #1
0
        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;
            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);
        }
Exemple #2
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);
            }
        }
Exemple #3
0
        bool Validate(PList plist)
        {
            var typeValue = plist.Root.StringValue(TYPE_KEY);

            if (string.IsNullOrEmpty(typeValue) || typeValue != TYPE_VALUE)
            {
                return(false);
            }

            var version = plist.Root.IntValue(VERSION_KEY);

            if (version != VERSION && !_supportedVersions.Contains(version))
            {
                return(false);
            }

            if (plist.Root.DictionaryValue(INFO_PLIST_KEY) == null)
            {
                return(false);
            }

            if (plist.Root.DictionaryValue(FRAMEWORKS_KEY) == null)
            {
                return(false);
            }

            if (plist.Root.DictionaryValue(FILES_AND_FOLDERS_KEY) == null)
            {
                return(false);
            }

            if (plist.Root.ArrayValue(BUILD_SETTINGS_KEY) == null)
            {
                return(false);
            }

            if (plist.Root.ArrayValue(SCRIPTS_KEY) == null)
            {
                return(false);
            }

            //signing section is optional for now
            //capabilities section is optional for now;
            return(true);
        }
Exemple #4
0
        bool Validate(PList plist)
        {
            var typeValue = plist.Root.StringValue(TYPE_KEY);

            if (string.IsNullOrEmpty(typeValue) || typeValue != TYPE_VALUE)
            {
                return(false);
            }

            var version = plist.Root.IntValue(VERSION_KEY);

            if (version != VERSION && !_supportedVersions.Contains(version))
            {
                return(false);
            }

            return(true);
        }
        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));
                }
            }
        }
        void ParseSettingsFile(PList plist)
        {
            _autoRun = plist.Root.BoolValue(AUTORUN_KEY);
            var ignoredFiles = plist.Root.ArrayValue(IGNORE_KEY);

            if (ignoredFiles != null)
            {
                var files = ignoredFiles.ToStringArray();
                IgnoredFiles.SetIngnoredFiles(files);
            }

            IsDirty = false;
            var version = plist.Root.Element <PListInteger>(VERSION_KEY);

            if (version.IntValue != VERSION)
            {
                version.IntValue = VERSION;
                IsDirty          = true;
            }
        }
        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));
                }
            }
        }
Exemple #8
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();
        }
Exemple #9
0
 bool ValidatePlist(PList plist)
 {
     return(plist.Root.StringValue(TYPE_KEY) == FILE_TYPE_VALUE);
 }
Exemple #10
0
        void LoadResourceBuildSettings()
        {
            PList plist = XcodeEditor.LoadResourcePlist(BUILD_SETTINGS_FILE);

            //check is right type
            if (!ValidatePlist(plist))
            {
                return;
            }

            //load the contents from the dic
            var settings = plist.Root.ArrayValue(BUILD_SETTINGS_KEY);

            if (settings == null)
            {
                return;
            }

            //populate the settings
            for (int ii = 0; ii < settings.Count; ++ii)
            {
                var         dic = settings.DictionaryValue(ii);
                SettingType type;

                try
                {
                    type = (SettingType)System.Enum.Parse(typeof(SettingType), dic.StringValue(TYPE_KEY));
                }
                catch
                {
                    Debug.LogError("EgoXproject: Unknown setting type in build settings database.");
                    continue;
                }

                switch (type)
                {
                case SettingType.Bool:
                    AddBool(dic);
                    break;

                case SettingType.Enum:
                    AddEnum(dic);
                    break;

                case SettingType.String:
                    AddString(dic);
                    break;

                case SettingType.Array:
                    AddArray(dic);
                    break;

                case SettingType.StringList:
                    AddStringList(dic);
                    break;

                default:
                    Debug.LogError("EgoXproject: Developer has forgot to implement code for a new type in the build settings database.");
                    break;
                }
            }
        }
 void ParseFile(PList plist)
 {
     _iosConfigs  = new PlatformConfiguration(plist.Root.DictionaryValue(BuildPlatform.iOS.ToString()));
     _tvosConfigs = new PlatformConfiguration(plist.Root.DictionaryValue(BuildPlatform.tvOS.ToString()));
     IsDirty      = false;
 }
        void LoadResourceBuildSettings()
        {
            Assembly myAssembly = Assembly.GetExecutingAssembly();
            Stream   stream     = myAssembly.GetManifestResourceStream(BUILD_SETTINGS_PLIST);

            if (stream == null)
            {
                return;
            }

            PList  plist   = new PList();
            string content = "";

            using (StreamReader reader = new StreamReader(stream))
            {
                content = reader.ReadToEnd();
            }

            if (!plist.LoadFromString(content))
            {
                return;
            }

            //check is right type
            if (!ValidatePlist(plist))
            {
                return;
            }

            //load the contents from the dic
            var settings = plist.Root.ArrayValue(BUILD_SETTINGS_KEY);

            if (settings == null)
            {
                return;
            }

            //populate the settings
            for (int ii = 0; ii < settings.Count; ++ii)
            {
                var         dic = settings.DictionaryValue(ii);
                SettingType type;

                try
                {
                    type = (SettingType)System.Enum.Parse(typeof(SettingType), dic.StringValue(TYPE_KEY));
                }
                catch
                {
                    Debug.LogError("EgoXproject: Unknown setting type in build settings database.");
                    continue;
                }

                switch (type)
                {
                case SettingType.Bool:
                    AddBool(dic);
                    break;

                case SettingType.Enum:
                    AddEnum(dic);
                    break;

                case SettingType.String:
                    AddString(dic);
                    break;

                case SettingType.Array:
                    AddArray(dic);
                    break;

                case SettingType.StringList:
                    AddStringList(dic);
                    break;

                default:
                    Debug.LogError("EgoXproject: Developer has forgot to implement code for a new type in the build settings database.");
                    break;
                }
            }
        }