Save() публичный Метод

Saves a project after editing.
public Save ( ) : void
Результат void
        public static void OnPostProcessBuild(BuildTarget target, string path)
        {
            // If integrating with facebook on any platform, throw a warning if the app id is invalid
            if (!FBSettings.IsValidAppId)
            {
                Debug.LogWarning("You didn't specify a Facebook app ID.  Please add one using the Facebook menu in the main Unity editor.");
            }

            bool needsNewClassnames = IsVersion42OrLater ();

            if (target == BuildTarget.iPhone)
            {
                UnityEditor.XCodeEditor.XCProject project = new UnityEditor.XCodeEditor.XCProject (path);

                // Find and run through all projmods files to patch the project

                string projModPath = System.IO.Path.Combine (Application.dataPath, "Facebook/Editor/iOS");
                var files = System.IO.Directory.GetFiles (projModPath, "*.projmods", System.IO.SearchOption.AllDirectories);
                foreach (var file in files)
                {
                    project.ApplyMod (Application.dataPath, file);
                }
                project.Save ();

                PlistMod.UpdatePlist (path, FBSettings.AppId);
                FixupFiles.FixSimulator (path);

                if(needsNewClassnames)
                    FixupFiles.AddVersionDefine (path);
            }
        }
Пример #2
0
	public static void OnPostProcessBuild( BuildTarget target, string pathToBuiltProject )
	{
		if (target != BuildTarget.iPhone) {
			Debug.LogWarning("Target is not iPhone. XCodePostProcess will not run");
			return;
		}

		// Create a new project object from build target
		XCProject project = new XCProject( pathToBuiltProject );

		// Find and run through all projmods files to patch the project.
		// Please pay attention that ALL projmods files in your project folder will be excuted!
		string[] files = Directory.GetFiles( Application.dataPath, "*.projmods", SearchOption.AllDirectories );
		foreach( string file in files ) {
			UnityEngine.Debug.Log("ProjMod File: "+file);
			project.ApplyMod( file );
		}

		//TODO implement generic settings as a module option
		project.overwriteBuildSetting("CODE_SIGN_IDENTITY[sdk=iphoneos*]", "iPhone Distribution", "Release");
		
		// Finally save the xcode project
		project.Save();

	}
Пример #3
0
	public static void OnPostProcessBuild( BuildTarget target, string pathToBuiltProject )
	{
		if (target != BuildTarget.iPhone) {
			Debug.LogWarning("Target is not iPhone. XCodePostProcess will not run");
			return;
		}

		Debug.Log("build dir is:" + pathToBuiltProject);
		int index = pathToBuiltProject.LastIndexOf("/");
		string folder = pathToBuiltProject.Substring(index + 1);
		Debug.Log("build folder is:" + folder);
		string[] sdks = folder.Split(new char[] { '_' });

		// Create a new project object from build target
		XCProject project = new XCProject( pathToBuiltProject );

		// Find and run through all projmods files to patch the project.
		// Please pay attention that ALL projmods files in your project folder will be excuted!
		string[] files = Directory.GetFiles( Path.Combine(Application.dataPath,"XUPorter"), "*.projmods", SearchOption.AllDirectories );
		foreach( string file in files ) {
			string filename = Path.GetFileNameWithoutExtension(file);
			Debug.Log("found ProjMod:" + filename);

			bool ismeet = false;
			if (filename == "common")
				ismeet = true;
			else
			{
				int meet = 0;
				string[] modsdks = filename.Split(new char[] { '_' });
				foreach (string modsdk in modsdks)
				{
					foreach (string sdk in sdks)
					{
						if (sdk == modsdk)
						{
							++meet;
							break;
						}
					}
					if(meet==0)
						break;
				}
				ismeet = meet == modsdks.Length;
			}
			string info = string.Format("ProjMod {0}: {1}", ismeet ? "accepted" : "ignored", file);
			UnityEngine.Debug.Log(info);
			if(ismeet)
				project.ApplyMod( file );
		}

		//TODO implement generic settings as a module option
		//project.overwriteBuildSetting("CODE_SIGN_IDENTITY[sdk=iphoneos*]", "iPhone Distribution", "Release");
		
		// Finally save the xcode project
		project.Save();

	}
    public static void OnPostProcessBuild(BuildTarget target2, string path)
    {
#if UNITY_5 || UNITY_5_3_OR_NEWER
        if (target2 == BuildTarget.iOS)
#else
        if (target2 == BuildTarget.iPhone)
#endif
        {
            UnityEditor.XCodeEditor.XCProject proj = new UnityEditor.XCodeEditor.XCProject(path);

            string   projmodsPath = System.IO.Path.Combine(Application.dataPath, "SDKPackage/PSSDK/Plugins/IOS/PostProcessBuild");
            string[] projmods     = System.IO.Directory.GetFiles(projmodsPath, "PSSDK.projmods", System.IO.SearchOption.AllDirectories);

            if (projmods.Length == 0)
            {
                Debug.LogWarning("[PSSDKPostBuild] PSSDK.projmods not found!");
            }
            foreach (string p in projmods)
            {
                proj.ApplyMod(p);
            }

            proj.AddOtherLinkerFlags("-ObjC");
            //proj.AddOtherLinkerFlags ("-fobjc-arc");
            proj.Save();

            // add info.plist
            string infoPlistPath = Path.Combine(Path.GetFullPath(path), "info.plist");
            var    plist         = new PlistDocument();
            plist.ReadFromString(File.ReadAllText(infoPlistPath));
            PlistElementDict root = plist.root;

            // NSAppTransportSecurity
            root.CreateDict("NSAppTransportSecurity").SetBoolean("NSAllowsArbitraryLoads", true);

            // Version
            PlistElementDict versionDict = (PlistElementDict)root["PackageSDKVersion"];
            if (versionDict == null)
            {
                versionDict = root.CreateDict("PackageSDKVersion");
            }

            PlistElementDict sdkVersionDict = versionDict.CreateDict("PSSDK");

            string iOS_SDK_Version       = PSSDKApi.iOS_SDK_Version;
            string Android_SDK_Version   = PSSDKApi.Android_SDK_Version;
            string Unity_Package_Version = PSSDKApi.Unity_Package_Version;


            sdkVersionDict.SetString("PSSDK_iOS_SDK_Version", iOS_SDK_Version);
            sdkVersionDict.SetString("PSSDK_Android_SDK_Version", Android_SDK_Version);
            sdkVersionDict.SetString("PSSDK_Unity_Package_Version", Unity_Package_Version);

            File.WriteAllText(infoPlistPath, plist.WriteToString());
        }
    }
Пример #5
0
        public static void OnPostProcessBuild(BuildTarget target, string path)
        {
            // If integrating with facebook on any platform, throw a warning if the app id is invalid
            if (!FBSettings.IsValidAppId)
            {
                Debug.LogWarning("You didn't specify a Facebook app ID.  Please add one using the Facebook menu in the main Unity editor.");
            }


                        #if UNITY_3_5 || UNITY_4_0 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3 || UNITY_4_5 || UNITY_4_6
            if (target == BuildTarget.iPhone)
                        #else
            if (target == BuildTarget.iOS)
                        #endif

            {
                UnityEditor.XCodeEditor.XCProject project = new UnityEditor.XCodeEditor.XCProject(path);

                // Find and run through all projmods files to patch the project

                string projModPath = System.IO.Path.Combine(Application.dataPath, "Facebook/Editor/iOS");
                var    files       = System.IO.Directory.GetFiles(projModPath, "*.projmods", System.IO.SearchOption.AllDirectories);
                foreach (var file in files)
                {
                    project.ApplyMod(Application.dataPath, file);
                }
                project.Save();

                UpdatePlist(path);
                FixupFiles.FixSimulator(path);
                FixupFiles.AddVersionDefine(path);
                FixupFiles.FixColdStart(path);
            }

            if (target == BuildTarget.Android)
            {
                // The default Bundle Identifier for Unity does magical things that causes bad stuff to happen
                if (PlayerSettings.bundleIdentifier == "com.Company.ProductName")
                {
                    Debug.LogError("The default Unity Bundle Identifier (com.Company.ProductName) will not work correctly.");
                }
                if (!FacebookAndroidUtil.IsSetupProperly())
                {
                    Debug.LogError("Your Android setup is not correct. See Settings in Facebook menu.");
                }

                if (!ManifestMod.CheckManifest())
                {
                    // If something is wrong with the Android Manifest, try to regenerate it to fix it for the next build.
                    ManifestMod.GenerateManifest();
                }
            }
        }
        public static void OnPostProcessBuild(BuildTarget target, string path)
        {
            Debug.Log("XUnityDeploy Post Process ....");
            if (target == BuildTarget.iOS)
            {
                var project = new UnityEditor.XCodeEditor.XCProject(path);

                var xcodeConfigPath = Path.Combine(Application.dataPath.Replace("Assets", ""), "XUnityDeploy/configs/xcode");

                var buildFilePath = Path.Combine(xcodeConfigPath, "main.build.json");
                Debug.Log("buildPath : " + buildFilePath);
                string buildContent = System.IO.File.ReadAllText(buildFilePath);

                var buildData   = MiniJSON.jsonDecode(buildContent) as Hashtable;
                var projmodList = buildData["projmods"] as ArrayList;

                // Find and run through all projmods files to patch the project
//                string projModPath = System.IO.Path.Combine(Application.dataPath, "Editor/iOS");
                var projModPath = xcodeConfigPath;
                for (int index = 0; index < projmodList.Count; ++index)
                {
                    var file = System.IO.Path.Combine(projModPath, projmodList[index].ToString());
                    Debug.Log(String.Format("Project ApplyMode : {0}", file));
                    try
                    {
                        project.ApplyMod(file);
                    }
                    catch (System.Exception ex)
                    {
                        //log
                        Debug.LogError("Project ApplyMode Exception : " + ex.Message + ex.StackTrace);
                        throw ex;
                    }
                }

                project.Save();

                var info        = buildData["info"] as string;
                var infoPath    = System.IO.Path.Combine(projModPath, info);
                var infoContent = System.IO.File.ReadAllText(infoPath);
                var infoData    = MiniJSON.jsonDecode(infoContent) as Hashtable;

                PlistMod.UpdatePlist_Extend(path, infoData);
            }

            if (target == BuildTarget.Android)
            {
                //TODO
            }
        }
        public static void OnPostProcessBuild(BuildTarget target, string path)
        {
            // If integrating with facebook on any platform, throw a warning if the app id is invalid
            if (!FBSettings.IsValidAppId)
            {
                Debug.LogWarning("You didn't specify a Facebook app ID.  Please add one using the Facebook menu in the main Unity editor.");
            }



            if (target == BuildTarget.iPhone)
            {
                UnityEditor.XCodeEditor.XCProject project = new UnityEditor.XCodeEditor.XCProject(path);

                // Find and run through all projmods files to patch the project

                string projModPath = System.IO.Path.Combine(Application.dataPath, "Facebook/Editor/iOS");
                var files = System.IO.Directory.GetFiles(projModPath, "*.projmods", System.IO.SearchOption.AllDirectories);
                foreach (var file in files)
                {
                    project.ApplyMod(Application.dataPath, file);
                }
                project.Save();

                PlistMod.UpdatePlist(path, FBSettings.AppId);
                FixupFiles.FixSimulator(path);
                FixupFiles.AddVersionDefine(path);
                FixupFiles.FixColdStart(path);
            }

            if (target == BuildTarget.Android)
            {
                // The default Bundle Identifier for Unity does magical things that causes bad stuff to happen
                if (PlayerSettings.bundleIdentifier == "com.Company.ProductName")
                {
                    Debug.LogError("The default Unity Bundle Identifier (com.Company.ProductName) will not work correctly.");
                }
                if (!FacebookAndroidUtil.IsSetupProperly())
                {
                    Debug.LogError("Your Android setup is not correct. See Settings in Facebook menu.");
                }

                if (!ManifestMod.CheckManifest())
                {
                    // If something is wrong with the Android Manifest, try to regenerate it to fix it for the next build.
                    ManifestMod.GenerateManifest();
                }
            }
        }
        public static void OnPostprocessBuild(BuildTarget target, string pathToBuiltProject)
        {
        #if UNITY_IOS
            //set a flag, next time biuld process if the flag exist, rebuild
            string flagPath = System.IO.Path.Combine(pathToBuiltProject, "unity_built_flag");



            if (!System.IO.File.Exists(flagPath))
            {
                System.IO.File.WriteAllText(flagPath, "built_time:" + System.DateTime.Now);
            }
            else
            {
                //adjusted the proj file, ignore
                return;
            }


            UnityEditor.XCodeEditor.XCProject project = new UnityEditor.XCodeEditor.XCProject(pathToBuiltProject);

            // Find and run through all projmods files to patch the project
            string projModPath = System.IO.Path.Combine(Application.dataPath, "Scripts/Editor");
            project.ApplyMod(Path.Combine(projModPath, "YoumeTalk.projmods"));
            //	project.overwriteBuildSetting("CODE_SIGN_IDENTITY[sdk=iphoneos*]", "iPhone Distribution", "Release");
            project.overwriteBuildSetting("ENABLE_BITCODE", "NO", "Release");
            project.overwriteBuildSetting("ENABLE_BITCODE", "NO", "Debug");
            Debug.Log("saving modified xcode proj file");
            project.Save();

            // const string fileName = "Info.plist";
            // string plistFilePath = System.IO.Path.Combine(pathToBuiltProject, fileName);
            //scheme is a string like: "wx|sdf3423sdfiopf"
            // InfoPlistEditor plistEditor = new InfoPlistEditor();
            // plistEditor.ReadFile(plistFilePath);
            //string[] tokens = s.Split('|');
            // string id = tokens[0];
            // string url = tokens[1];
            // plistEditor.AppendUrlScheme(id, url);
            // plistEditor.AppendKeyValue(key,value);
            // plistEditor.Save(plistFilePath);
        #endif
        }
Пример #9
0
        public static void OnPostProcessBuild(BuildTarget target, string path)
        {
            // If integrating with facebook on any platform, throw a warning if the app id is invalid
            if (!FBSettings.IsValidAppId)
            {
                Debug.LogWarning("You didn't specify a Facebook app ID.  Please add one using the Facebook menu in the main Unity editor.");
            }

            bool needsNewClassnames = IsVersion42OrLater();

            if (target == BuildTarget.iPhone)
            {
                UnityEditor.XCodeEditor.XCProject project = new UnityEditor.XCodeEditor.XCProject(path);

                // Find and run through all projmods files to patch the project

                string projModPath = System.IO.Path.Combine(Application.dataPath, "Facebook/Editor/iOS");
                var    files       = System.IO.Directory.GetFiles(projModPath, "*.projmods", System.IO.SearchOption.AllDirectories);
                foreach (var file in files)
                {
                    project.ApplyMod(Application.dataPath, file);
                }
                project.Save();

                PlistMod.UpdatePlist(path, FBSettings.AppId);
                FixupFiles.FixSimulator(path);

                if (needsNewClassnames)
                {
                    FixupFiles.AddVersionDefine(path);
                }
            }

            if (target == BuildTarget.Android)
            {
                // The default Bundle Identifier for Unity does magical things that causes bad stuff to happen
                if (PlayerSettings.bundleIdentifier == "com.Company.ProductName")
                {
                    Debug.LogError("The default Unity Bundle Identifier (com.Company.ProductName) will not work correctly.");
                }
            }
        }
Пример #10
0
    public static void OnPostProcessBuild( BuildTarget target, string path )
    {
        if (target != BuildTarget.iPhone) {
            Debug.LogWarning("Target is not iPhone. XCodePostProcess will not run");
            return;
        }

        // Create a new project object from build target
        XCProject project = new XCProject( path );

        // Find and run through all projmods files to patch the project.
        //Please pay attention that ALL projmods files in your project folder will be excuted!
        string[] files = Directory.GetFiles( Application.dataPath, "*.projmods", SearchOption.AllDirectories );
        foreach( string file in files ) {
            project.ApplyMod( file );
        }

        // Finally save the xcode project
        project.Save();
    }
Пример #11
0
    public static void EdittingPbxProj(string pathToBuiltProject)
    {
        // Xcode 프로젝트 불러오기.(project.pbxproj 수정 용도.)
        XCProject prj = new XCProject(pathToBuiltProject);

        // .projmods적용. 외부 프래임워크 추가, 파일 복사(폴더).
        string[] files = Directory.GetFiles(Application.dataPath + "/Editor/XcodeProjectMods", "*.projmods", SearchOption.AllDirectories);
        foreach( string file in files )
            prj.ApplyMod( file );

        // 테스트로 아무 프로비저닝이나 추가함.
        prj.overwriteBuildSetting("CODE_SIGN_NAME_IDENTITY[sdk=iphoneos*]", CODE_SIGN_NAME, "Release");
        prj.overwriteBuildSetting("CODE_SIGN_NAME_IDENTITY[sdk=iphoneos*]", CODE_SIGN_NAME, "Debug");
        prj.overwriteBuildSetting("CODE_SIGN_NAME_IDENTITY", CODE_SIGN_NAME, "Release");
        prj.overwriteBuildSetting("CODE_SIGN_NAME_IDENTITY", CODE_SIGN_NAME, "Debug");
        prj.overwriteBuildSetting("PROVISIONING_PROFILE", PROVISIONING_UUID, "Release");
        prj.overwriteBuildSetting("PROVISIONING_PROFILE", PROVISIONING_UUID, "Debug");

        // 설정이 변경된 프로젝트 저장.
        prj.Save();
    }
Пример #12
0
    public static void OnPostProcessBuild(BuildTarget target, string pathToBuiltProject)
    {
        if (target != BuildTarget.iOS)
        {
            Debug.LogWarning("Target is not iPhone. XCodePostProcess will not run");
            return;
        }

        //得到xcode工程的路径
        string path = Path.GetFullPath(pathToBuiltProject);

        // Create a new project object from build target
        XCProject project = new XCProject(pathToBuiltProject);

        // Find and run through all projmods files to patch the project.
        // Please pay attention that ALL projmods files in your project folder will be excuted!
        //在这里面把frameworks添加在你的xcode工程里面
        string[] files = Directory.GetFiles(Application.dataPath, "*.projmods", SearchOption.AllDirectories);
        foreach (string file in files)
        {
            project.ApplyMod(file);
        }

        ////增加一个编译标记。。没有的话sharesdk会报错。。    
        //project.AddOtherLinkerFlags("-licucore");

        ////设置签名的证书, 第二个参数 你可以设置成你的证书
        //project.overwriteBuildSetting("CODE_SIGN_IDENTITY", "xxxxxx", "Release");
        //project.overwriteBuildSetting("CODE_SIGN_IDENTITY", "xxxxxx", "Debug");


        //// 编辑plist 文件
        //EditorPlist(path);

        ////编辑代码文件
        //EditorCode(path);

        // Finally save the xcode project
        project.Save();
    }
        public static void OnPostprocessBuild( BuildTarget target, string path )
        {
            if (BuildTarget.iPhone == target) {
                                // Create a new project object from build target
                                XCodeEditor.XCProject project = new XCodeEditor.XCProject (path);
                                //Debug.Log ("project has been created using path: "+path);
                                // Find and run through all projmods files to patch the project
                                //Debug.Log ("searching for projmods files in:" +Application.dataPath);
                                var files = System.IO.Directory.GetFiles (Application.dataPath+"/Editor/iOS", "*.projmods", SearchOption.AllDirectories);
                                foreach (var file in files) {
                                        Debug.Log (file.ToString());
                                        project.ApplyMod (file);
                                }
                                if (files.Length <= 0) {
                                        Debug.Log ("no .projmods files found");
                                }

                                // Finally save the xcode project
                                project.Save ();

                        }
        }
Пример #14
0
    public static void OnPostProcessBuild(BuildTarget target, string path)
    {
        if (target == BuildTarget.iOS)
        {
            // Create a new project object from build target
            UnityEditor.XCodeEditor.XCProject project = new UnityEditor.XCodeEditor.XCProject(path);

            string projModPath = System.IO.Path.Combine(Application.dataPath, "XCodeEditor");
            // Find and run through all projmods files to patch the project
            var files = System.IO.Directory.GetFiles(projModPath, "*.projmods", SearchOption.AllDirectories);
            foreach (var file in files)
            {
                project.ApplyMod(file);
            }

            // Finally save the xcode project
            project.Save();


            // Update 7plist for Facebook
//			UnityEditor.FacebookEditor.XCodePostProcess.UpdatePlist(path);
        }
    }
Пример #15
0
        public static string AddNewBuildFile(IIgorModule ModuleInst, string ProjectPath, string FileRefGUID)
        {
            if(IgorAssert.EnsureTrue(ModuleInst, Directory.Exists(ProjectPath), "XCodeProj doesn't exist at path " + ProjectPath))
            {
                XCProject CurrentProject = new XCProject(ProjectPath);

                CurrentProject.Backup();

                foreach(KeyValuePair<string, PBXBuildFile> CurrentBuildFile in CurrentProject.buildFiles)
                {
                    if(IgorAssert.EnsureTrue(ModuleInst, CurrentBuildFile.Value.ContainsKey("fileRef"), "PBXBuildFile doesn't contain a key for fileRef."))
                    {
                        if(CurrentBuildFile.Value.data["fileRef"] == FileRefGUID)
                        {
                            IgorDebug.Log(ModuleInst, "The file GUID " + FileRefGUID + " already has an associated BuildFile in the XCodeProj.");

                            return CurrentBuildFile.Value.guid;
                        }
                    }
                }

                foreach(KeyValuePair<string, PBXFileReference> CurrentFileRef in CurrentProject.fileReferences)
                {
                    if(CurrentFileRef.Value.guid == FileRefGUID)
                    {
                        PBXBuildFile NewBuildFile = new PBXBuildFile(CurrentFileRef.Value);

                        CurrentProject.buildFiles.Add(NewBuildFile);

                        IgorDebug.Log(ModuleInst, "BuildFile for FileRefGUID " + FileRefGUID + " has been added to the XCodeProj.");

                        CurrentProject.Save();

                        return NewBuildFile.guid;
                    }
                }
            }

            return "";
        }
Пример #16
0
    public static void OnPostProcessBuild(BuildTarget target2, string path)
    {
#if UNITY_5 || UNITY_5_3_OR_NEWER
        if (target2 == BuildTarget.iOS)
#else
        if (target2 == BuildTarget.iPhone)
#endif
        {
            UnityEditor.XCodeEditor.XCProject proj = new UnityEditor.XCodeEditor.XCProject(path);

            string[] projmods = System.IO.Directory.GetFiles(
                System.IO.Path.Combine(System.IO.Path.Combine(Application.dataPath, "PolyADSDK"), "Plugins"), "PolyADSDK.projmods", System.IO.SearchOption.AllDirectories);
            if (projmods.Length == 0)
            {
                Debug.LogWarning("[PolyPostBuild]PolyADSDK.projmods not found!");
            }
            foreach (string p in projmods)
            {
                proj.ApplyMod(p);
            }

            proj.AddOtherLinkerFlags("-ObjC");
            proj.AddOtherLinkerFlags("-fobjc-arc");
            proj.Save();


            // delete android assets file of avidly

            string avidlypath = System.IO.Path.Combine(System.IO.Path.Combine(proj.projectRootPath, "Data"), "Raw");
            Debug.Log("==> path1:" + avidlypath);
            if (System.IO.Directory.Exists(avidlypath))
            {
                avidlypath = System.IO.Path.Combine(avidlypath, "avidly_android");
                Debug.Log("==> path2:" + avidlypath);
                if (System.IO.Directory.Exists(avidlypath))
                {
                    Debug.Log("==> exist avidly_android, will delete allfiles");
                    string [] avidlyfiles = System.IO.Directory.GetFiles(avidlypath);
                    foreach (string p in avidlyfiles)
                    {
                        Debug.Log("==> to del:" + p);
                        if (System.IO.File.Exists(p))
                        {
                            System.IO.File.Delete(p);
                            Debug.Log("==> to del finish");
                        }
                    }
                }
            }

            string filePath = Path.GetFullPath(path);
            Debug.Log("==> filePath " + filePath);
            string infofilePath = Path.Combine(filePath, "info.plist");
            Debug.Log("==> infofilePath " + infofilePath);

            if (!System.IO.File.Exists(infofilePath))
            {
                Debug.LogError(infofilePath + ", 路径下文件不存在");
                return;
            }

            Dictionary <string, object> dict = (Dictionary <string, object>)PlistCS.Plist.readPlist(infofilePath);
            string dkey = "AppLovinSdkKey";
            if (!dict.ContainsKey(dkey))
            {
                dict.Add(dkey, "e-4s7LbXsuJb2oXtoW10amMsJ9scHJhwHmmP6LxzEEZH159qbBqBxA2FKvsbCXWUIHuPdqMs2w840HucShoOtq");
                PlistCS.Plist.writeXml(dict, infofilePath);
                Debug.Log("==> add " + dkey + " :" + dict [dkey]);
            }
            else
            {
                Debug.Log("==> exist " + dkey + " :" + dict[dkey]);
            }
            dkey = "NSAppTransportSecurity";
            if (!dict.ContainsKey(dkey))
            {
                Dictionary <string, bool> dv = new Dictionary <string, bool>();
                dv.Add("NSAllowsArbitraryLoads", true);
                dict.Add(dkey, dv);
                Debug.Log("==> add " + dkey + " :" + dict [dkey]);
            }
            else
            {
                Debug.Log("==> exist " + dkey + " :" + dict[dkey]);
            }

            string pluginspath = System.IO.Path.Combine(System.IO.Path.Combine(Application.dataPath, "PolyADSDK"), "Plugins");
            Debug.Log("==> pluginspath " + pluginspath);
            if (System.IO.File.Exists(pluginspath))
            {
                string iospath = System.IO.Path.Combine(pluginspath, "IOS");
                Debug.Log("==> iospath " + iospath);
                if (System.IO.File.Exists(iospath))
                {
                    string fmpath = System.IO.Path.Combine(iospath, "frameworks");
                    if (System.IO.File.Exists(fmpath))
                    {
                        string adcolonypath = System.IO.Path.Combine(fmpath, "AdColony.framework");
                        if (System.IO.File.Exists(adcolonypath))
                        {
                            System.IO.File.Delete(adcolonypath);
                            Debug.Log("==> del exist " + adcolonypath);
                        }

                        string delfmpath = System.IO.Path.Combine(fmpath, "FBAudienceNetwork.framework");
                        if (System.IO.File.Exists(delfmpath))
                        {
                            System.IO.File.Delete(delfmpath);
                            Debug.Log("==> del exist " + delfmpath);
                        }

                        delfmpath = System.IO.Path.Combine(fmpath, "GoogleMobileAds.framework");
                        if (System.IO.File.Exists(delfmpath))
                        {
                            System.IO.File.Delete(delfmpath);
                            Debug.Log("==> del exist " + delfmpath);
                        }

                        delfmpath = System.IO.Path.Combine(fmpath, "MVSDK.framework");
                        if (System.IO.File.Exists(delfmpath))
                        {
                            System.IO.File.Delete(delfmpath);
                            Debug.Log("==> del exist " + delfmpath);
                        }

                        delfmpath = System.IO.Path.Combine(fmpath, "MVSDKReward.framework");
                        if (System.IO.File.Exists(delfmpath))
                        {
                            System.IO.File.Delete(delfmpath);
                            Debug.Log("==> del exist " + delfmpath);
                        }

                        delfmpath = System.IO.Path.Combine(fmpath, "UnityAds.framework");
                        if (System.IO.File.Exists(delfmpath))
                        {
                            System.IO.File.Delete(delfmpath);
                            Debug.Log("==> del exist " + delfmpath);
                        }

                        delfmpath = System.IO.Path.Combine(fmpath, "VungleSDK.framework");
                        if (System.IO.File.Exists(delfmpath))
                        {
                            System.IO.File.Delete(delfmpath);
                            Debug.Log("==> del exist " + delfmpath);
                        }
                    }
                }
            }

            //在plist里面增加一行

            //list.AddKey(PlistAdd);
            //在plist里面替换一行
            //list.ReplaceKey("<string>com.yusong.${PRODUCT_NAME}</string>","<string>"+bundle+"</string>");
            //保存
            //list.Save();


            //string projPath = PBXProject.GenerateGuid ();
            //PBXProject pbxProject = new PBXProject ();



//			proj.AddEmbedFramework ("WebKit.framework");
//			proj.AddEmbedFramework ("libsqlite3.tbd");
//			proj.AddEmbedFramework ("libz.tbd");
//			proj.AddOtherLinkerFlags("-ObjC");
//			proj.Save();

//			string projPath = PBXProject.GetPBXProjectPath (path);
//			PBXProject proj = new PBXProject ();
//
//
//			proj.ReadFromString (File.ReadAllText (projPath));
//			string target = proj.TargetGuidByName ("Unity-iPhone");
//
//			// add extra framework(s)
//			proj.AddFrameworkToProject (target, "WebKit.framework", true);
//			proj.AddFrameworkToProject (target, "libsqlite3.tbd", true);
//			proj.AddFrameworkToProject (target, "libz.tbd", true);
//			proj.AddBuildProperty(target, "OTHER_LDFLAGS", "-ObjC");
//
//			File.WriteAllText(projPath, proj.WriteToString());

            // project.overwriteBuildSetting("ENABLE_BITCODE", "NO", "Release");
            // project.overwriteBuildSetting("ENABLE_BITCODE", "NO", "Debug");
            //project.AddOtherLinkerFlags("-ObjC");
            //project.Save();
        }
    }
Пример #17
0
        public static void SortGUIDIntoGroup(IIgorModule ModuleInst, string ProjectPath, string FileGUID, string GroupPath)
        {
            if(IgorAssert.EnsureTrue(ModuleInst, Directory.Exists(ProjectPath), "XCodeProj doesn't exist at path " + ProjectPath))
            {
                XCProject CurrentProject = new XCProject(ProjectPath);

                CurrentProject.Backup();

                if(IgorAssert.EnsureTrue(ModuleInst, CurrentProject != null, "XCodeProj couldn't be loaded."))
                {
                    bool bFoundGroup = false;

                    foreach(KeyValuePair<string, PBXGroup> CurrentGroup in CurrentProject.groups)
                    {
                        if(CurrentGroup.Value.path == GroupPath)
                        {
                            if(IgorAssert.EnsureTrue(ModuleInst, CurrentGroup.Value.ContainsKey("children"), "XCodeProj PBXGroup " + GroupPath + " doesn't have a children array."))
                            {
                                object GroupChildrenObj = CurrentGroup.Value.data["children"];

                                if(IgorAssert.EnsureTrue(ModuleInst, GroupChildrenObj != null, "XCodeProj PBXGroup " + GroupPath + " has a children key, but it can't be retrieved."))
                                {
                                    if(IgorAssert.EnsureTrue(ModuleInst, typeof(PBXList).IsAssignableFrom(GroupChildrenObj.GetType()), "XCodeProj PBXGroup " + GroupPath + " has a children key, but it can't be cast to PBXList."))
                                    {
                                        PBXList GroupChildrenList = (PBXList)GroupChildrenObj;

                                        if(IgorAssert.EnsureTrue(ModuleInst, GroupChildrenList != null, "XCodeProj casted Children List is null."))
                                        {
                                            if(GroupChildrenList.Contains(FileGUID))
                                            {
                                                IgorDebug.Log(ModuleInst, "FileGUID " + FileGUID + " has already been added to the Group " + CurrentGroup.Key + ".");
                                            }
                                            else
                                            {
                                                GroupChildrenList.Add(FileGUID);

                                                CurrentGroup.Value.data["children"] = GroupChildrenList;

                                                IgorDebug.Log(ModuleInst, "Added the " + FileGUID + " file to the Group " + CurrentGroup.Key + ".");
                                            }
                                        }
                                    }
                                }

                                bFoundGroup = true;

                                break;
                            }
                        }
                    }

                    IgorAssert.EnsureTrue(ModuleInst, bFoundGroup, "Couldn't find a PBXGroup with path " + GroupPath + " in the XCodeProj.");

                    CurrentProject.Save();
                }
            }
        }
Пример #18
0
        public static void SetDevTeamID(IIgorModule ModuleInst, string ProjectPath, string DevTeamID)
        {
            if(IgorAssert.EnsureTrue(ModuleInst, Directory.Exists(ProjectPath), "XCodeProj doesn't exist at path " + ProjectPath))
            {
                XCProject CurrentProject = new XCProject(ProjectPath);

                CurrentProject.Backup();

                string ProjectGUID = CurrentProject.project.guid;

                object ProjectSectionObj = CurrentProject.GetObject(ProjectGUID);

                if(IgorAssert.EnsureTrue(ModuleInst, ProjectSectionObj != null, "Can't find Project Section in XCodeProj."))
                {
                    PBXDictionary ProjectSection = (PBXDictionary)ProjectSectionObj;

                    object AttributesSectionObj = ProjectSection["attributes"];

                    if(IgorAssert.EnsureTrue(ModuleInst, AttributesSectionObj != null, "Can't find Attributes Section in Project Section."))
                    {
                        object TargetAttributesObj = ((PBXDictionary)AttributesSectionObj)["TargetAttributes"];

                        if(IgorAssert.EnsureTrue(ModuleInst, TargetAttributesObj != null, "Can't find TargetAttributes Section in Attributes Section."))
                        {
                            PBXDictionary TargetAttributes = (PBXDictionary)TargetAttributesObj;

                            object TargetsObj = ProjectSection["targets"];

                            if(IgorAssert.EnsureTrue(ModuleInst, TargetsObj != null, "Can't find Targets Section in Project Section."))
                            {
                                PBXList TargetsList = ((PBXList)TargetsObj);

                                if(IgorAssert.EnsureTrue(ModuleInst, TargetsList.Count > 0, "No build targets defined in XCodeProj."))
                                {
                                    string PrimaryBuildTargetGUID = (string)(TargetsList[0]);

                                    PBXDictionary PrimaryBuildTargetToDevTeam = new PBXDictionary();
                                    PBXDictionary DevTeamIDDictionary = new PBXDictionary();

                                    DevTeamIDDictionary.Add("DevelopmentTeam", DevTeamID);

                                    PrimaryBuildTargetToDevTeam.Add(PrimaryBuildTargetGUID, DevTeamIDDictionary);

                                    if(TargetAttributes.ContainsKey(PrimaryBuildTargetGUID))
                                    {
                                        object ExistingPrimaryBuildTargetObj = TargetAttributes[PrimaryBuildTargetGUID];

                                        if(ExistingPrimaryBuildTargetObj != null)
                                        {
                                            PBXDictionary ExistingPrimaryBuildTarget = (PBXDictionary)ExistingPrimaryBuildTargetObj;

                                            if(!ExistingPrimaryBuildTarget.ContainsKey("DevelopmentTeam"))
                                            {
                                                ExistingPrimaryBuildTarget.Append(DevTeamIDDictionary);

                                                IgorDebug.Log(ModuleInst, "Added Development Team to XCodeProj.");
                                            }
                                            else
                                            {
                                                IgorDebug.Log(ModuleInst, "Development Team already set up in XCodeProj.");
                                            }
                                        }
                                        else
                                        {
                                            IgorDebug.LogError(ModuleInst, "Primary build target already has a key in TargetAttributes, but the value stored is invalid.");
                                        }
                                    }
                                    else
                                    {
                                        TargetAttributes.Append(PrimaryBuildTargetToDevTeam);

                                        IgorDebug.Log(ModuleInst, "Added Development Team to XCodeProj.");
                                    }

                                    CurrentProject.Save();
                                }
                            }
                        }
                    }
                }
            }
        }
Пример #19
0
        public static void AddOrUpdateForAllBuildProducts(IIgorModule ModuleInst, string ProjectPath, string Key, string Value)
        {
            if(IgorAssert.EnsureTrue(ModuleInst, Directory.Exists(ProjectPath), "XCodeProj doesn't exist at path " + ProjectPath))
            {
                XCProject CurrentProject = new XCProject(ProjectPath);

                CurrentProject.Backup();

                foreach(KeyValuePair<string, XCBuildConfiguration> CurrentConfig in CurrentProject.buildConfigurations)
                {
                    object BuildSettingsObj = CurrentConfig.Value.data["buildSettings"];
                    PBXDictionary BuildSettingsDict = (PBXDictionary)BuildSettingsObj;

                    if(BuildSettingsDict.ContainsKey(Key))
                    {
                        BuildSettingsDict[Key] = Value;

                        IgorDebug.Log(ModuleInst, "Updated KeyValuePair (Key: " + Key + " Value: " + Value + ") to build target GUID " + CurrentConfig.Key);
                    }
                    else
                    {
                        BuildSettingsDict.Add(Key, Value);

                        IgorDebug.Log(ModuleInst, "Added new KeyValuePair (Key: " + Key + " Value: " + Value + ") to build target GUID " + CurrentConfig.Key);
                    }
                }

                CurrentProject.Save();
            }
        }
Пример #20
0
        public static void AddFramework(IIgorModule ModuleInst, string ProjectPath, string Filename, TreeEnum TreeBase, string Path = "", int FileEncoding = -1, string LastKnownFileType = "", string Name = "")
        {
            string FrameworkFileRefGUID = AddNewFileReference(ModuleInst, ProjectPath, Filename, TreeBase, Path, FileEncoding, LastKnownFileType, Name);

            if(IgorAssert.EnsureTrue(ModuleInst, Directory.Exists(ProjectPath), "XCodeProj doesn't exist at path " + ProjectPath))
            {
                XCProject CurrentProject = new XCProject(ProjectPath);

                CurrentProject.Backup();

                if(IgorAssert.EnsureTrue(ModuleInst, CurrentProject != null, "XCodeProj couldn't be loaded."))
                {
                    bool bFoundFrameworksGroup = false;

                    foreach(KeyValuePair<string, PBXGroup> CurrentGroup in CurrentProject.groups)
                    {
                        if(CurrentGroup.Value.name == "Frameworks")
                        {
                            if(IgorAssert.EnsureTrue(ModuleInst, CurrentGroup.Value.ContainsKey("children"), "XCodeProj Frameworks PBXGroup doesn't have a children array."))
                            {
                                object FrameworkChildrenObj = CurrentGroup.Value.data["children"];

                                if(IgorAssert.EnsureTrue(ModuleInst, FrameworkChildrenObj != null, "XCodeProj Frameworks PBXGroup has a children key, but it can't be retrieved."))
                                {
                                    if(IgorAssert.EnsureTrue(ModuleInst, typeof(PBXList).IsAssignableFrom(FrameworkChildrenObj.GetType()), "XCodeProj Frameworks PBXGroup has a children key, but it can't be cast to PBXList."))
                                    {
                                        PBXList FrameworkChildrenList = (PBXList)FrameworkChildrenObj;

                                        if(IgorAssert.EnsureTrue(ModuleInst, FrameworkChildrenList != null, "XCodeProj casted Framework Children List is null."))
                                        {
                                            if(FrameworkChildrenList.Contains(FrameworkFileRefGUID))
                                            {
                                                IgorDebug.Log(ModuleInst, "Framework " + Filename + " has already been added to the Framework Group " + CurrentGroup.Key + ".");
                                            }
                                            else
                                            {
                                                FrameworkChildrenList.Add(FrameworkFileRefGUID);

                                                CurrentGroup.Value.data["children"] = FrameworkChildrenList;

                                                IgorDebug.Log(ModuleInst, "Added the " + Filename + " framework to the Framework Group " + CurrentGroup.Key + ".");
                                            }
                                        }
                                    }
                                }

                                bFoundFrameworksGroup = true;

                                break;
                            }
                        }
                    }

                    IgorAssert.EnsureTrue(ModuleInst, bFoundFrameworksGroup, "Couldn't find a Frameworks PBXGroup in the XCodeProj.");

                    CurrentProject.Save();
                }
            }

            string FrameworkBuildFileGUID = AddNewBuildFile(ModuleInst, ProjectPath, FrameworkFileRefGUID);

            if(IgorAssert.EnsureTrue(ModuleInst, Directory.Exists(ProjectPath), "XCodeProj doesn't exist at path " + ProjectPath))
            {
                XCProject CurrentProject = new XCProject(ProjectPath);

                CurrentProject.Backup();

                if(IgorAssert.EnsureTrue(ModuleInst, CurrentProject != null, "XCodeProj couldn't be loaded."))
                {
                    foreach(KeyValuePair<string, PBXFrameworksBuildPhase> CurrentTarget in CurrentProject.frameworkBuildPhases)
                    {
                        if(IgorAssert.EnsureTrue(ModuleInst, CurrentTarget.Value.ContainsKey("files"), "XCodeProj Framework Build Phase doesn't have a files array."))
                        {
                            object FrameworkFilesObj = CurrentTarget.Value.data["files"];

                            if(IgorAssert.EnsureTrue(ModuleInst, FrameworkFilesObj != null, "XCodeProj Framework Build Phase has a files key, but it can't be retrieved."))
                            {
                                if(IgorAssert.EnsureTrue(ModuleInst, typeof(PBXList).IsAssignableFrom(FrameworkFilesObj.GetType()), "XCodeProj Framework Build Phase has a files key, but it can't be cast to PBXList."))
                                {
                                    PBXList FrameworkFilesList = (PBXList)FrameworkFilesObj;

                                    if(IgorAssert.EnsureTrue(ModuleInst, FrameworkFilesList != null, "XCodeProj casted Framework File List is null."))
                                    {
                                        if(FrameworkFilesList.Contains(FrameworkBuildFileGUID))
                                        {
                                            IgorDebug.Log(ModuleInst, "Framework " + Filename + " has already been added to the Framework Build Phase " + CurrentTarget.Key + ".");
                                        }
                                        else
                                        {
                                            FrameworkFilesList.Add(FrameworkBuildFileGUID);

                                            CurrentTarget.Value.data["files"] = FrameworkFilesList;

                                            IgorDebug.Log(ModuleInst, "Added the " + Filename + " framework to the Framework Build Phase " + CurrentTarget.Key + ".");
                                        }
                                    }
                                }
                            }
                        }
                    }

                    CurrentProject.Save();
                }
            }
        }
Пример #21
0
        public static string AddNewFileReference(IIgorModule ModuleInst, string ProjectPath, string Filename, TreeEnum TreeBase, string Path = "", int FileEncoding = -1, string LastKnownFileType = "", string Name = "")
        {
            if(IgorAssert.EnsureTrue(ModuleInst, Directory.Exists(ProjectPath), "XCodeProj doesn't exist at path " + ProjectPath))
            {
                XCProject CurrentProject = new XCProject(ProjectPath);

                CurrentProject.Backup();

                foreach(KeyValuePair<string, PBXFileReference> CurrentFileRef in CurrentProject.fileReferences)
                {
                    if(CurrentFileRef.Value.name == Filename)
                    {
                        IgorDebug.Log(ModuleInst, "The file " + Filename + " is already referenced in the XCodeProj.");

                        return CurrentFileRef.Value.guid;
                    }
                }

                PBXFileReference NewFile = new PBXFileReference(Filename, TreeBase);

                if(Path != "")
                {
                    if(NewFile.ContainsKey("path"))
                    {
                        NewFile.Remove("path");
                    }

                    NewFile.Add("path", Path);
                }

                if(FileEncoding != -1)
                {
                    if(NewFile.ContainsKey("fileEncoding"))
                    {
                        NewFile.Remove("fileEncoding");
                    }

                    NewFile.Add("fileEncoding", FileEncoding);
                }

                if(LastKnownFileType != "")
                {
                    if(NewFile.ContainsKey("lastKnownFileType"))
                    {
                        NewFile.Remove("lastKnownFileType");
                    }

                    NewFile.Add("lastKnownFileType", LastKnownFileType);
                }

                if(Name != "")
                {
                    if(NewFile.ContainsKey("name"))
                    {
                        NewFile.Remove("name");
                    }

                    NewFile.Add("name", Name);
                }

                CurrentProject.fileReferences.Add(NewFile);

                IgorDebug.Log(ModuleInst, "File " + Filename + " has been added to the XCodeProj.");

                CurrentProject.Save();

                return NewFile.guid;
            }

            return "";
        }
Пример #22
0
        public static void AddFrameworkSearchPath(IIgorModule ModuleInst, string ProjectPath, string NewPath)
        {
            if(IgorAssert.EnsureTrue(ModuleInst, Directory.Exists(ProjectPath), "XCodeProj doesn't exist at path " + ProjectPath))
            {
                XCProject CurrentProject = new XCProject(ProjectPath);

                CurrentProject.Backup();

                CurrentProject.AddFrameworkSearchPaths(NewPath);

                IgorDebug.Log(ModuleInst, "Added framework search path " + NewPath);

                CurrentProject.Save();
            }
        }