public static void OnPostprocessBuild(BuildTarget target, string projectPath) { var pbxProjPath = PBXProject.GetPBXProjectPath(projectPath); PBXProject proj = new PBXProject(); proj.ReadFromFile(pbxProjPath); string targetGuid = proj.TargetGuidByName("Unity-iPhone"); RegisterAppLanguages(); AddFlags(proj, targetGuid); AddLibraries(proj, targetGuid); AddFrameworks(proj, targetGuid, target); AddEmbededFrameworks(proj, targetGuid); AddPlistVariables(projectPath); ApplyBuildSettings(proj, targetGuid); CopyAssetFiles(proj, projectPath, targetGuid); AddShellScriptBuildPhase(proj, targetGuid); proj.WriteToFile(pbxProjPath); var capManager = new ProjectCapabilityManager(pbxProjPath, ISD_Settings.ENTITLEMENTS_FILE_NAME, "Unity-iPhone"); AddCapabilities(proj, targetGuid, capManager); capManager.WriteToFile(); //Some API simply does not work so on this block we are applying a workaround //after Unity deploy scrips has stopped working //Addons EmbededFrameworks foreach (var framework in ISD_Settings.Instance.EmbededFrameworks) { string contents = File.ReadAllText(pbxProjPath); string pattern = "(?<=Embed Frameworks)(?:.*)(\\/\\* " + framework.FileName + "\\ \\*\\/)(?=; };)"; string oldText = "/* " + framework.FileName + " */"; string updatedText = "/* " + framework.FileName + " */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }"; contents = Regex.Replace(contents, pattern, m => m.Value.Replace(oldText, updatedText)); File.WriteAllText(pbxProjPath, contents); } var entitlementsPath = projectPath + "/" + ISD_Settings.ENTITLEMENTS_FILE_NAME; if (ISD_Settings.Instance.EntitlementsMode == ISD_EntitlementsGenerationMode.Automatic) { if (ISD_Settings.Instance.Capability.iCloud.Enabled) { if (ISD_Settings.Instance.Capability.iCloud.keyValueStorage && !ISD_Settings.Instance.Capability.iCloud.iCloudDocument) { var entitlements = new PlistDocument(); entitlements.ReadFromFile(entitlementsPath); var plistVariable = new PlistElementArray(); entitlements.root["com.apple.developer.icloud-container-identifiers"] = plistVariable; entitlements.WriteToFile(entitlementsPath); } } } else { if (ISD_Settings.Instance.EntitlementsFile != null) { var entitlementsContentPath = SA_AssetDatabase.GetAbsoluteAssetPath(ISD_Settings.Instance.EntitlementsFile); string contents = File.ReadAllText(entitlementsContentPath); File.WriteAllText(entitlementsPath, contents); } else { Debug.LogWarning("ISD: EntitlementsMode set to Manual but no file provided"); } } }