Example #1
0
        // 添加 URLTypes
        public static bool AddURLTypes(PlistDocument doc, string role, string URLName, string schemes)
        {
            PlistElementArray urlTypes = null;

            try
            {
                urlTypes = (PlistElementArray)doc.root.values["CFBundleURLTypes"];
            }
            catch (Exception e)
            {
            }

            if (urlTypes == null)
            {
                urlTypes = doc.root.CreateArray("CFBundleURLTypes");
            }

            var urlDict = urlTypes.AddDict();

            urlDict.SetString("CFBundleTypeRole", role);
            urlDict.SetString("CFBundleURLName", URLName);
            urlDict.CreateArray("CFBundleURLSchemes").AddString(schemes);

            return(true);
        }
Example #2
0
        public static bool ChangeInfoPlist(string pathToBuiltProject, ChangeInfoPlistStep step)
        {
            string plistPath = Path.Combine(pathToBuiltProject, "Info.plist");

            if (!File.Exists(plistPath))
            {
                Debug.LogError("[MSLDPostProcess][iOS][ChangeInfoPlist]:plistPath Not exists. plistPath:" + plistPath);
                return(false);
            }

            Debug.Log("[MSLDPostProcess][iOS][ChangeInfoPlist]: plistPath: " + plistPath);

            var doc = new PlistDocument();

            doc.ReadFromFile(plistPath);

            if (doc == null)
            {
                Debug.LogError("[MSLDPostProcess][iOS][ChangeInfoPlist]:PlistDocument is null. plistPath:" + plistPath);
                return(false);
            }

            if (step != null)
            {
                if (step(doc))
                {
                    doc.WriteToFile(plistPath);
                }
                else
                {
                    Debug.LogError("[MSLDPostProcess][iOS][ChangeInfoPlist]:  step false");
                    return(false);
                }
            }

            return(true);
        }
Example #3
0
        //private static void AddEmbedFrameworks(PBXProject proj, string targetGuid, string framework)
        //{
        //    //string fileGuid = proj.AddFile("usr/lib/" + lib, "Frameworks/" + lib, PBXSourceTree.Sdk);
        //    //proj.AddFileToBuild(targetGuid, fileGuid);


        //    string framework = Path.Combine(frameworkPath, fwk);
        //    string fileGuid = proj.AddFile(framework, "Frameworks/" + framework, PBXSourceTree.Sdk);
        //    PBXProjectExtensions.AddFileToEmbedFrameworks(proj, target, fileGuid);

        //    proj.SetBuildProperty(target, "LD_RUNPATH_SEARCH_PATHS", "$(inherited) @executable_path/Frameworks");
        //}

        // 添加 LSApplicationQueriesSchemes
        public static bool AddApplicationQueriesSchemes(PlistDocument doc, string[] schemes)
        {
            PlistElementArray queriesSchemes = null;

            try
            {
                queriesSchemes = (PlistElementArray)doc.root.values["LSApplicationQueriesSchemes"];
            }
            catch (Exception e)
            {
            }

            if (queriesSchemes == null)
            {
                queriesSchemes = doc.root.CreateArray("LSApplicationQueriesSchemes");
            }

            foreach (string scheme in schemes)
            {
                queriesSchemes.AddString(scheme);
            }

            return(true);
        }