Esempio n. 1
0
    /// <summary>
    /// 用unity自带的打包api设置info.plist
    /// </summary>
    /// <param name="pathToBuiltProject"></param>
    private static void EditInfoPlistWithUnity(string pathToBuiltProject)
    {
        string plistPath = pathToBuiltProject + "/Info.plist";

        UnityEditor.iOS.Xcode.Custom.PlistDocument plist = new UnityEditor.iOS.Xcode.Custom.PlistDocument();
        plist.ReadFromString(File.ReadAllText(plistPath));
        UnityEditor.iOS.Xcode.Custom.PlistElementDict rootDict = plist.root;
        packageManager.EditInfoPlistWithUnity(rootDict);
        plist.WriteToFile(plistPath);
    }
Esempio n. 2
0
        public static void OnPostprocessBuild(string xcodePath, string configPath)
        {
            pluginPath = configPath.Replace("XcodeSetting.json", "");
            string     projPath = PBXProject.GetPBXProjectPath(xcodePath);
            PBXProject proj     = new PBXProject();

            proj.ReadFromString(File.ReadAllText(projPath));
            //读取配置文件
            string    json  = File.ReadAllText(configPath);
            Hashtable table = json.hashtableFromJson();

            //lib
            SetLibs(proj, table.SGet <Hashtable>("libs"));
            //framework
            SetFrameworks(proj, table.SGet <Hashtable>("frameworks"));
            //building setting
            SetBuildProperties(proj, table.SGet <Hashtable>("properties"));
            //复制文件
            CopyFiles(proj, xcodePath, table.SGet <Hashtable>("files"));
            //复制文件夹
            CopyFolders(proj, xcodePath, table.SGet <Hashtable>("folders"));
            //文件编译符号
            SetFilesCompileFlag(proj, table.SGet <Hashtable>("filesCompileFlag"));
            //写入
            File.WriteAllText(projPath, proj.WriteToString());
            //plist
            string        plistPath = xcodePath + "/Info.plist";
            PlistDocument plist     = new PlistDocument();

            plist.ReadFromString(File.ReadAllText(plistPath));
            PlistElementDict rootDict = plist.root;

            SetPlist(proj, rootDict, table.SGet <Hashtable>("plist"));
            //写入
            plist.WriteToFile(plistPath);
        }