Exemple #1
0
        // Takes the build path where Info.plist is located
        // and a Dictionary<string, PlistElementDict> (kitsInfo) where
        // key: the KitName and
        // value: a PlistElementDict containing the KitInfo
        protected static void AddFabricKitsToPlist(string buildPath, Dictionary<string, PlistElementDict> kitsInfo)
        {
            Utils.Log ("Preparing Info.plist");

            Settings settings = Settings.Instance;
            string plistPath = Path.Combine (buildPath, "Info.plist");

            PlistDocument plist = new PlistDocument();
            plist.ReadFromFile(plistPath);

            PlistElementDict rootDict = plist.root.AsDict ();
            PlistElementDict fabricEl = (PlistElementDict)rootDict["Fabric"];
            if (fabricEl == null) {
                fabricEl = plist.root.CreateDict("Fabric");
            }
            fabricEl.SetString("APIKey", settings.Organization.ApiKey);

            PlistElementArray fabricKits = (PlistElementArray)fabricEl["Kits"];
            if (fabricKits == null) {
                fabricKits = fabricEl.CreateArray("Kits");
            }

            foreach (KeyValuePair<string, PlistElementDict> entry in kitsInfo) {
                Utils.Log ("Adding kit {0} to Info.plist", entry.Key);

                PlistElementDict kitDict = fabricKits.AddDict();
                kitDict.SetString("KitName", entry.Key);
                kitDict["KitInfo"] = entry.Value;
            }

            plist.WriteToFile(plistPath);
        }
		private static void AddCrashlyticsVersionToPlist (string buildPath)
		{
			Utils.Log ("Adding Crashlytics version to Info.plist");

			string plistPath = Path.Combine (buildPath, "Info.plist");			
			PlistDocument plist = new PlistDocument();

			plist.ReadFromFile(plistPath);
			plist.root.SetString("CrashlyticsUnityVersion", Info.Version.ToString());
			plist.WriteToFile(plistPath);
		}
        private static void ModifyFabricPlistElement(string buildPath, System.Action<PlistElementDict> modify)
        {
            string plistPath = Path.Combine (buildPath, "Info.plist");

            PlistDocument plist = new PlistDocument ();
            plist.ReadFromFile (plistPath);

            PlistElementDict rootDict = plist.root.AsDict ();
            PlistElementDict fabric = (PlistElementDict)rootDict ["Fabric"] ?? plist.root.CreateDict ("Fabric");

            modify (fabric);

            plist.WriteToFile (plistPath);
        }