public void OnPostprocessBuild(BuildTarget target, string pathToBuiltProject) { if (target == BuildTarget.WSAPlayer) { AddInternetClientCapability(pathToBuiltProject); AddHelperCodeToUWPProject(pathToBuiltProject); if (PlayerSettings.GetScriptingBackend(BuildTargetGroup.WSA) != ScriptingImplementation.IL2CPP) { // If UWP with .NET scripting backend, need to add NuGet packages. var projectJson = pathToBuiltProject + "/" + PlayerSettings.productName + "/project.json"; AddDependenciesToProjectJson(projectJson); var nuget = EditorApplication.applicationContentsPath + "/PlaybackEngines/MetroSupport/Tools/nuget.exe"; ExecuteCommand(nuget, "restore \"" + projectJson + "\" -NonInteractive"); } else { // Fix System.Diagnostics.Debug IL2CPP implementation. FixIl2CppLogging(pathToBuiltProject); } } if (target == BuildTarget.iOS && PBXProjectWrapper.PBXProjectIsAvailable && PlistDocumentWrapper.PlistDocumentIsAvailable) { var pbxProject = new PBXProjectWrapper(pathToBuiltProject); // Update project. OnPostprocessProject(pbxProject); pbxProject.WriteToFile(); // Update Info.plist. var settings = AppCenterSettingsContext.SettingsInstance; var infoPath = pathToBuiltProject + "/Info.plist"; var info = new PlistDocumentWrapper(infoPath); OnPostprocessInfo(info, settings); info.WriteToFile(); // Update capabilities (if possible). if (ProjectCapabilityManagerWrapper.ProjectCapabilityManagerIsAvailable) { var capabilityManager = new ProjectCapabilityManagerWrapper(pbxProject.ProjectPath, PBXProjectWrapper.GetUnityTargetName()); OnPostprocessCapabilities(capabilityManager, settings); capabilityManager.WriteToFile(); } } }
private static void OnPostprocessInfo(PlistDocumentWrapper info, AppCenterSettings settings) { if (settings.UseDistribute && AppCenter.Distribute != null) { // Add App Center URL sceme. var root = info.GetRoot(); var urlTypes = root.GetType().GetMethod("CreateArray").Invoke(root, new object[] { "CFBundleURLTypes" }); if (settings.UseDistribute && AppCenter.Distribute != null) { var urlType = urlTypes.GetType().GetMethod("AddDict").Invoke(urlTypes, null); var setStringMethod = urlType.GetType().GetMethod("SetString"); setStringMethod.Invoke(urlType, new object[] { "CFBundleTypeRole", "None" }); setStringMethod.Invoke(urlType, new object[] { "CFBundleURLName", ApplicationIdHelper.GetApplicationId() }); var urlSchemes = urlType.GetType().GetMethod("CreateArray").Invoke(urlType, new[] { "CFBundleURLSchemes" }); urlSchemes.GetType().GetMethod("AddString").Invoke(urlSchemes, new[] { "appcenter-" + settings.iOSAppSecret }); } } }
private static void OnPostprocessInfo(PlistDocumentWrapper info, AppCenterSettings settings) { if (settings.UseDistribute && AppCenter.Distribute != null) { // Add App Center URL scemes. var schemes = new List <string>() { "appcenter-" + settings.iOSAppSecret }; // Create a reflection call for getting custom schemes from iOS settings. var playerSettingsClass = typeof(PlayerSettings.iOS); var iOSURLSchemesMethod = playerSettingsClass.GetMethod("GetURLSchemes", BindingFlags.Static | BindingFlags.NonPublic); // Verify that method exists and call it for getting custom schemes. if (iOSURLSchemesMethod != null) { var schemesFromSettings = (string[])iOSURLSchemesMethod.Invoke(null, null); schemes.AddRange(schemesFromSettings.ToList <string>()); } // Generate scheme information. var root = info.GetRoot(); var urlTypes = root.GetType().GetMethod("CreateArray").Invoke(root, new object[] { "CFBundleURLTypes" }); if (settings.UseDistribute && AppCenter.Distribute != null) { var urlType = urlTypes.GetType().GetMethod("AddDict").Invoke(urlTypes, null); var setStringMethod = urlType.GetType().GetMethod("SetString"); setStringMethod.Invoke(urlType, new object[] { "CFBundleTypeRole", "None" }); setStringMethod.Invoke(urlType, new object[] { "CFBundleURLName", ApplicationIdHelper.GetApplicationId() }); var urlSchemes = urlType.GetType().GetMethod("CreateArray").Invoke(urlType, new[] { "CFBundleURLSchemes" }); // Add custom schemes defined in Unity players settings. foreach (var scheme in schemes) { urlSchemes.GetType().GetMethod("AddString").Invoke(urlSchemes, new[] { scheme }); } } } }
public void OnPostprocessBuild(BuildTarget target, string pathToBuiltProject) { if (target == BuildTarget.WSAPlayer) { AddInternetClientCapability(pathToBuiltProject); AddHelperCodeToUWPProject(pathToBuiltProject); if (PlayerSettings.GetScriptingBackend(BuildTargetGroup.WSA) == ScriptingImplementation.IL2CPP) { // Fix System.Diagnostics.Debug IL2CPP implementation. FixIl2CppLogging(pathToBuiltProject); } } if (target == BuildTarget.iOS && PBXProjectWrapper.PBXProjectIsAvailable && PlistDocumentWrapper.PlistDocumentIsAvailable) { var pbxProject = new PBXProjectWrapper(pathToBuiltProject); // Update project. OnPostprocessProject(pbxProject); pbxProject.WriteToFile(); // Update Info.plist. var settings = AppCenterSettingsContext.SettingsInstance; var infoPath = pathToBuiltProject + "/Info.plist"; var info = new PlistDocumentWrapper(infoPath); OnPostprocessInfo(info, settings); info.WriteToFile(); // Update capabilities (if possible). if (ProjectCapabilityManagerWrapper.ProjectCapabilityManagerIsAvailable) { var capabilityManager = new ProjectCapabilityManagerWrapper(pbxProject.ProjectPath, PBXProjectWrapper.GetUnityTargetName(), pbxProject.GetUnityTargetGuid()); OnPostprocessCapabilities(capabilityManager, settings); capabilityManager.WriteToFile(); } } }