Ejemplo n.º 1
0
        public static void Main(string[] args)
        {
            string command = args[0];

            if (command == "--pbx")
            {
                string xcodePath  = args[1];
                string configPath = args[2];
                Console.WriteLine("xcodePath=" + xcodePath + " configPath=" + configPath);
                XcodeSetting.OnPostprocessBuild(xcodePath, configPath);
                Console.WriteLine("********XcodeSetting success");
            }
            else if (command == "--pod")
            {
                string xcodePath  = args[1];
                string configPath = args[2];
                string podType    = args[3]; //workspace,project
                try {
                    object cocoaPodType = Enum.Parse(typeof(IOSResolver.CocoapodsIntegrationMethod), podType);
                    IOSResolver.OnPosetProcess(xcodePath, configPath, cocoaPodType);
                } catch (Exception ex) {
                    Console.WriteLine(string.Format("CocoaPodType is null.['Workspace','Project','None']   msg:{0} \nStackTrace:{1}"
                                                    , ex.Message, ex.StackTrace));
                }
            }

            // object cocoaPodType = Enum.Parse (typeof (IOSResolver.CocoapodsIntegrationMethod), "Project");
            // IOSResolver.OnPosetProcess("E:\\github\\usdk\\publish\\ios\\build\\baidu", "E:\\github\\usdk\\publish\\ios\\sdk\\plugins\\Bugly\\module\\CocoapodsDependencies.json", cocoaPodType);
            // XcodeSetting.OnPostprocessBuild("E:\\github\\usdk\\publish\\ios\\build\\baidu", "E:\\github\\usdk\\publish\\ios\\sdk\\plugins\\Bugly\\module\\XcodeSetting.json");
            // Console.ReadKey();
        }
        static XcodeProjectPatcher()
        {
            XcodeProjectPatcher.PROJECT_KEYS = new string[]
            {
                "CLIENT_ID",
                "REVERSED_CLIENT_ID",
                "BUNDLE_ID",
                "PROJECT_ID",
                "STORAGE_BUCKET",
                "DATABASE_URL"
            };
            XcodeProjectPatcher.configValues = new Dictionary <string, string>();
            XcodeProjectPatcher.allBundleIds = new HashSet <string>();
            XcodeProjectPatcher.configFile   = null;
            IOSResolver.RemapXcodeExtension();
            Delegate arg_7C_0 = EditorApplication.update;

            if (XcodeProjectPatcher.f__mgcache0 == null)
            {
                XcodeProjectPatcher.f__mgcache0 = new EditorApplication.CallbackFunction(XcodeProjectPatcher.ReadConfigOnUpdate);
            }
            EditorApplication.update = (EditorApplication.CallbackFunction)Delegate.Remove(arg_7C_0, XcodeProjectPatcher.f__mgcache0);
            Delegate arg_AD_0 = EditorApplication.update;

            if (XcodeProjectPatcher.f__mgcache1 == null)
            {
                XcodeProjectPatcher.f__mgcache1 = new EditorApplication.CallbackFunction(XcodeProjectPatcher.ReadConfigOnUpdate);
            }
            EditorApplication.update = (EditorApplication.CallbackFunction)Delegate.Combine(arg_AD_0, XcodeProjectPatcher.f__mgcache1);
            if (XcodeProjectPatcher.f__mgcache2 == null)
            {
                XcodeProjectPatcher.f__mgcache2 = new EventHandler <PlayServicesResolver.BundleIdChangedEventArgs>(XcodeProjectPatcher.OnBundleIdChanged);
            }
            PlayServicesResolver.BundleIdChanged -= XcodeProjectPatcher.f__mgcache2;//.remove_BundleIdChanged(XcodeProjectPatcher.f__mgcache2);
            Delegate arg_100_0 = EditorApplication.update;

            if (XcodeProjectPatcher.f__mgcache3 == null)
            {
                XcodeProjectPatcher.f__mgcache3 = new EditorApplication.CallbackFunction(XcodeProjectPatcher.CheckConfiguration);
            }
            EditorApplication.update = (EditorApplication.CallbackFunction)Delegate.Remove(arg_100_0, XcodeProjectPatcher.f__mgcache3);
            if (XcodeProjectPatcher.Enabled)
            {
                if (XcodeProjectPatcher.f__mgcache4 == null)
                {
                    XcodeProjectPatcher.f__mgcache4 = new EventHandler <PlayServicesResolver.BundleIdChangedEventArgs>(XcodeProjectPatcher.OnBundleIdChanged);
                }
                PlayServicesResolver.BundleIdChanged += XcodeProjectPatcher.f__mgcache4;
                Delegate arg_15D_0 = EditorApplication.update;
                if (XcodeProjectPatcher.f__mgcache5 == null)
                {
                    XcodeProjectPatcher.f__mgcache5 = new EditorApplication.CallbackFunction(XcodeProjectPatcher.CheckConfiguration);
                }
                EditorApplication.update = (EditorApplication.CallbackFunction)Delegate.Combine(arg_15D_0, XcodeProjectPatcher.f__mgcache5);
            }
        }
        internal static void AddGoogleServicePlist(BuildTarget buildTarget, string pathToBuiltProject)
        {
            XcodeProjectPatcher.ReadConfig(true, null);
            if (XcodeProjectPatcher.configFile == null)
            {
                return;
            }
            XcodeProjectPatcher.CheckBundleId(UnityCompat.ApplicationId, false, true);
            string fileName = Path.GetFileName(XcodeProjectPatcher.configFile);

            File.Copy(XcodeProjectPatcher.configFile, Path.Combine(pathToBuiltProject, fileName), true);
            string     projectPath = IOSResolver.GetProjectPath(pathToBuiltProject);
            PBXProject pBXProject  = new PBXProject();

            pBXProject.ReadFromString(File.ReadAllText(projectPath));
            pBXProject.AddFileToBuild(pBXProject.TargetGuidByName(IOSResolver.TARGET_NAME), pBXProject.AddFile(fileName, fileName, PBXSourceTree.Source));
            File.WriteAllText(projectPath, pBXProject.WriteToString());
        }
Ejemplo n.º 4
0
        public static void OnPostProcess(BuildTarget target, string path)
        {
            if (target != BuildTarget.iOS)
            {
                return;
            }
            // XCProj
            string projPath = PBXProject.GetPBXProjectPath(path);

            PBXProject proj = new PBXProject();

            proj.ReadFromString(File.ReadAllText(projPath));

            string targetName    = "Unity-iPhone";
            string projectTarget = proj.TargetGuidByName(targetName);

            proj.AddBuildProperty(projectTarget, "SWIFT_OBJC_BRIDGING_HEADER", "Libraries/Platform/iOS/Unity-iPhone-Bridging-Header.h");
            proj.AddBuildProperty(projectTarget, "SWIFT_VERSION", swiftVersion);
            File.WriteAllText(projPath, proj.WriteToString());

            // Podfile
            var podfile = $"{path}/Podfile";

            if (!File.Exists(podfile))
            {
                Debug.LogError($"No podfile found at {podfile}. Creating Empty one.");
                return;
            }

            Debug.Log($"Podfile found at {podfile}. Adding use_frameworks!");
            var lines = File.ReadAllLines(podfile).ToList();

            lines.Insert(0, "use_frameworks!");
            File.WriteAllLines(podfile, lines);

            // Unfortunately we have to re-run the install. This sucks.
            IOSResolver.OnPostProcessInstallPods(target, path);
        }