Example #1
0
        public ProjectBasicConfig GetConfig(PackageChannel channel)
        {
            if (!File.Exists(BuildPaths.ProjectBasicConfigFilePath))
            {
                Debug.LogError("xcode basic config not found!");
                return(null);
            }

            ProjectBasicConfig config = new ProjectBasicConfig();

            string[] signingConfig = File.ReadAllLines(BuildPaths.ProjectBasicConfigFilePath);

            string channelFlag = "channel=" + ChannelToStr(channel);

            for (int i = 0; i < signingConfig.Length; ++i)
            {
                string lineContent = signingConfig[i];

                if (!lineContent.Contains(channelFlag))
                {
                    continue;
                }

                while (!signingConfig[++i].Contains("code_signing_identity"))
                {
                }
                config.CodeSigningIdentify = ClipConfigValue(signingConfig[i].Trim());

                while (!signingConfig[++i].Contains("provisioning_profile"))
                {
                }
                config.ProvisioningProfile = ClipConfigValue(signingConfig[i].Trim());

                while (!signingConfig[++i].Contains("provisioning_profile_specifier"))
                {
                }
                config.ProvisioningProfileSpecifier = ClipConfigValue(signingConfig[i].Trim());

                while (!signingConfig[++i].Contains("team_id"))
                {
                }
                config.TeamId = ClipConfigValue(signingConfig[i].Trim());

                while (!signingConfig[++i].Contains("bundle_identity"))
                {
                }
                config.BundleIdentity = ClipConfigValue(signingConfig[i].Trim());

                while (!signingConfig[++i].Contains("display_name"))
                {
                }
                config.DisplayName = ClipConfigValue(signingConfig[i].Trim());

                config.Dump();

                return(config);
            }

            return(null);
        }
        private static void OverWriteInfoPlist(ProjectBasicConfig config, string xcodeProjectPath, ProjectBuildData data)
        {
            XCPlist plist = new XCPlist(xcodeProjectPath + "Info.plist");

            Dictionary <string, object> configItems = new Dictionary <string, object>
            {
                { XCPlist.CFBundleDisplayName, config.DisplayName },
                { XCPlist.CFBundleShortVersionString, data.IdentityVersion },
                { XCPlist.CFBundleVersion, data.IdentityBuild }
            };

            plist.OverWriteItems(configItems);
        }
        private static void OverWriteBuildSetting(ProjectBasicConfig config, XCProject project)
        {
            project.overwriteBuildSetting("CODE_SIGN_IDENTITY", config.CodeSigningIdentify, "Debug");
            project.overwriteBuildSetting("CODE_SIGN_IDENTITY", config.CodeSigningIdentify, "Release");

            project.overwriteBuildSetting("PROVISIONING_PROFILE", config.ProvisioningProfile, "Release");
            project.overwriteBuildSetting("PROVISIONING_PROFILE", config.ProvisioningProfile, "Debug");
            project.overwriteBuildSetting("PROVISIONING_PROFILE_SPECIFIER", config.ProvisioningProfileSpecifier, "Debug");
            project.overwriteBuildSetting("PROVISIONING_PROFILE_SPECIFIER", config.ProvisioningProfileSpecifier, "Release");

            project.overwriteBuildSetting("DEVELOPMENT_TEAM", config.TeamId, "Release");
            project.overwriteBuildSetting("DEVELOPMENT_TEAM", config.TeamId, "Debug");

            project.overwriteBuildSetting("PRODUCT_BUNDLE_IDENTIFIER", config.BundleIdentity);

            string[] bundleIdentifyParts = config.BundleIdentity.Split('.');
            project.overwriteBuildSetting("PRODUCT_NAME", bundleIdentifyParts[bundleIdentifyParts.Length - 1]);

            project.overwriteBuildSetting("ENABLE_BITCODE", "NO");
        }