static void CopyIcons(string path, BasePackageConfig config) { string srcDir = path + config.AppIconsPath; string destDir = path + "/Unity-iPhone/Images.xcassets/AppIcon.appiconset/"; string[] iconNames = new string[] { "Icon-72.png", "Icon-76.png", "Icon-120.png", "Icon-144.png", "Icon-152.png", "Icon-167.png", "Icon-180.png", "Icon-Small-40.png", "Icon-Small-80.png", "Icon-Small-120.png", "Icon-Small.png", "*****@*****.**", "*****@*****.**", "Icon.png", "*****@*****.**", "Icon-1024.jpg", "Contents.json" }; CopyImages(srcDir, destDir, iconNames); }
static void ConfigureChannelFiles(bool isIWChannel) { if (isIWChannel) { BasePackageConfig iwBuildConfig = PackageConfigManager.Instance.GetiOSBuildConfig(true); BasePackageConfig normalBuildConfig = PackageConfigManager.Instance.GetiOSBuildConfig(false); Dictionary <string, string> pathInfoDic = new Dictionary <string, string> { { Application.dataPath + iwBuildConfig.LoadingTexPath + "loading0000000000.jpg", Application.dataPath + normalBuildConfig.LoadingTexPath + "loading0000000000.jpg" }, { Application.dataPath + iwBuildConfig.SvUdidFilePath + "SvUDIDTools.m", Application.dataPath + normalBuildConfig.SvUdidFilePath + "SvUDIDTools.m" } }; foreach (var pathInfo in pathInfoDic) { string srcPath = pathInfo.Key; string desPath = pathInfo.Value; FileInfo file = new FileInfo(srcPath); if (file.Exists) { file.CopyTo(desPath, true); } } AssetDatabase.Refresh(); } }
static void CopySplashImages(string path, BasePackageConfig config) { string srcDir = path + config.SplashIconsPath; string destDir = path + "/Unity-iPhone/Images.xcassets/LaunchImage.launchimage/"; string[] splashNames = new string[] { //landscape "Default-Landscape.png", "*****@*****.**", "*****@*****.**", //portrait "*****@*****.**", "*****@*****.**", "Default-Portrait.png", "*****@*****.**", "*****@*****.**", "Default.png", "*****@*****.**" }; CopyImages(srcDir, destDir, splashNames); string destDir2 = path + "/"; string[] screenNames = new string[] { //screen "LaunchScreen-iPad.png", "LaunchScreen-iPhoneLandscape.png", "LaunchScreen-iPhonePortrait.png" }; CopyImages(srcDir, destDir2, screenNames); }
private static void EditorPlist(string filePath, BasePackageConfig config) { XCPlistCustom list = new XCPlistCustom(filePath); string applovinSdkKey = config.AppLovinSdkKey; string fbAppId = config.FacebookAppId; string plistAdd = @" <key>CFBundleURLTypes</key> <array> <dict> <key>CFBundleURLName</key> <string>HugeWinSlots</string> <key>CFBundleURLSchemes</key> <array> <string>hugewinslots</string> </array> </dict> <dict> <key>CFBundleURLName</key> <string>facebook-unity-sdk</string> <key>CFBundleURLSchemes</key> <array> <string>fb" + fbAppId + @"</string> </array> </dict> </array> <key>AppLovinSdkKey</key> <string>" + applovinSdkKey + @"</string> <key>ITSAppUsesNonExemptEncryption</key> <false/> <key>UIBackgroundModes</key> <array> <string>remote-notification</string> </array>" ; list.AddKey(plistAdd); list.Save(); }
static void SetFacebookAppId(BasePackageConfig packageConfig) { Facebook.Unity.Settings.FacebookSettings.SelectedAppIndex = packageConfig.FacebookAppIdIndex; Debug.Log("Select Facebook AppId: " + Facebook.Unity.Settings.FacebookSettings.AppId); }
static void CommandLineBuildIphone() { SwitchBuildPlatform(BuildTarget.iOS); Debug.Log("\n------------------\nStart build iOS from command line\n------------------\n"); string[] scenes = GetBuildScenes(); string path = GetIOSBuildPath(); CheckScenes(scenes); BasePackageConfig packageConfig = PackageConfigManager.Instance.GetiOSBuildConfig(GetiOSChannelType() == ChannelType.iOS_IW.ToString()); SetIOSBuildVersion(); SetIOSBuildBundleId(packageConfig); SetiOSProductName(packageConfig); WriteIOSVersionCode(); string symbol = GetBuildSymbol(); string defineSymbols = ""; bool isiOSIWChannel = GetiOSChannelType() == ChannelType.iOS_IW.ToString(); if (symbol == "Debug") { EditorUserBuildSettings.development = true; defineSymbols = isiOSIWChannel ? "DEBUG;Trojan_FB;USE_iOS_IW" : "DEBUG;Trojan_FB"; PlayerSettings.SetScriptingDefineSymbolsForGroup(BuildTargetGroup.iOS, defineSymbols); } else if (symbol == "Release") { EditorUserBuildSettings.development = false; defineSymbols = isiOSIWChannel ? "RELEASE;Trojan_FB;USE_iOS_IW" : "RELEASE;Trojan_FB"; PlayerSettings.SetScriptingDefineSymbolsForGroup(BuildTargetGroup.iOS, defineSymbols); } else if (symbol == "Release_AppStore") { EditorUserBuildSettings.development = false; defineSymbols = isiOSIWChannel ? "RELEASE;RELEASE_APPSTORE;Trojan_FB;USE_iOS_IW" : "RELEASE;RELEASE_APPSTORE;Trojan_FB"; PlayerSettings.SetScriptingDefineSymbolsForGroup(BuildTargetGroup.iOS, defineSymbols); } else { Debug.LogError("Error: no Debug or Release symbol is indicated"); } SetFacebookAppId(packageConfig); ConfigureChannelFiles(isiOSIWChannel); //DeleteFabricIcon (); PreProcessBuildPlayer(BuildTarget.iOS); string message = UnityEditor.BuildPipeline.BuildPlayer(scenes, path, BuildTarget.iOS, BuildOptions.None); if (message.IsNullOrEmpty()) { System.Console.WriteLine("BuildPlayer Success!"); } else { System.Console.WriteLine("BuildPlayer error message: " + message.ToString()); } PostProcessBuildPlayer(); }
static void SetiOSProductName(BasePackageConfig packageConfig) { PlayerSettings.productName = packageConfig.ProductName; }
static void SetIOSBuildBundleId(BasePackageConfig packageConfig) { PlayerSettings.bundleIdentifier = packageConfig.iOSBundleIdentifier; }
public static void OnPostProcessBuild(BuildTarget target, string pathToBuiltProject) { if (target != BuildTarget.iOS) { Debug.LogWarning("Target is not iPhone. XCodePostProcess will not run"); return; } string path = Path.GetFullPath(pathToBuiltProject); bool isDebugBuild = GetIsAppBuildSymbol("Debug"); bool isReleaseBuild = GetIsAppBuildSymbol("Release"); // 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); if (file.Contains("Debug")) { if (isDebugBuild) { Debug.Log("debug applymod is " + file); project.ApplyMod(file); } } else if (file.Contains("Release")) { if (isReleaseBuild) { Debug.Log("release applymod is " + file); project.ApplyMod(file); } } else { Debug.Log("applymod is " + file); project.ApplyMod(file); } } project.overwriteBuildSetting("GCC_ENABLE_CPP_RTTI", "YES"); //if OC exceptions is disabled, sensor iOS compile will fail project.overwriteBuildSetting("GCC_ENABLE_OBJC_EXCEPTIONS", "YES"); SetProvisioningStyle(project); //todo: should enable Bitcode for release? project.overwriteBuildSetting("ENABLE_BITCODE", "NO"); project.overwriteBuildSetting("CODE_SIGN_IDENTITY", "iPhone Developer", "Debug"); project.overwriteBuildSetting("CODE_SIGN_IDENTITY", "iPhone Developer", "ReleaseForProfiling"); project.overwriteBuildSetting("CODE_SIGN_IDENTITY", "iPhone Developer", "ReleaseForRunning"); BasePackageConfig packageConfig = PackageConfigManager.Instance.GetiOSBuildConfig(GetIsIOSIWBuild()); project.overwriteBuildSetting("CODE_SIGN_IDENTITY", packageConfig.DistributionCertification, "Release"); string provisionDev = ""; provisionDev = packageConfig.iOSProvisionDev; project.overwriteBuildSetting("PROVISIONING_PROFILE", provisionDev, "Debug"); project.overwriteBuildSetting("PROVISIONING_PROFILE", provisionDev, "ReleaseForProfiling"); project.overwriteBuildSetting("PROVISIONING_PROFILE", provisionDev, "ReleaseForRunning"); //AdHoc //project.overwriteBuildSetting("PROVISIONING_PROFILE", "ea67fd45-afa7-4314-87a6-d7294f32bd1a", "Release"); //AppStore //project.overwriteBuildSetting("PROVISIONING_PROFILE", "5488674a-c55f-4c7f-8538-f44cae39cb06", "Release"); string releaseProvisionFile = ""; bool isAppStore = GetIsAppBuildSymbol("Release_AppStore"); if (isAppStore) { releaseProvisionFile = packageConfig.iOSProvisionAppstore; } else { releaseProvisionFile = packageConfig.iOSProvisionAdhoc; } project.overwriteBuildSetting("PROVISIONING_PROFILE", releaseProvisionFile, "Release"); // project.overwriteBuildSetting("PROVISIONING_PROFILE_SPECIFIDER", "MJ42U9V8CF/20170119_trojan_dev", "Debug"); // project.overwriteBuildSetting("PROVISIONING_PROFILE_SPECIFIDER", "MJ42U9V8CF/20170119_trojan_dev", "ReleaseForProfiling"); // project.overwriteBuildSetting("PROVISIONING_PROFILE_SPECIFIDER", "MJ42U9V8CF/20170119_trojan_dev", "ReleaseForRunning"); // project.overwriteBuildSetting("PROVISIONING_PROFILE_SPECIFIDER", "MJ42U9V8CF/20170120_trojan_appstore", "Release"); project.overwriteBuildSetting("DEVELOPMENT_TEAM", packageConfig.CertificationId); project.overwriteBuildSetting("CLANG_ENABLE_MODULES", "YES"); // project.overwriteBuildSetting ("VALID_ARCHS", "arm64 armv7s"); // project.overwriteBuildSetting ("GCC_GENERATE_DEBUGGING_SYMBOLS", "NO"); //keychain setting project.overwriteBuildSetting("CODE_SIGN_ENTITLEMENTS", "KeychainAccessGroups.plist"); string keychainSrcPath = ""; string keychainDestPath = path + "/KeychainAccessGroups.plist"; if (isDebugBuild) { keychainSrcPath = packageConfig.KeychainPlistDebugPath; } else if (isReleaseBuild) { keychainSrcPath = packageConfig.KeychainPlistReleasePath; } FileCopy(path + keychainSrcPath, keychainDestPath); // SetKeychain(project); SetPushEnable(project); EditorPlist(path, packageConfig); EditorCode(path); CopySplashImages(path, packageConfig); CopyIcons(path, packageConfig); //AddIcons(pathToBuiltProject); // Finally save the xcode project project.Save(); UnityEngine.Debug.Log("XCodePostProcess Sucess"); }