public static void OnPostProcessEnableNotificationExtension( BuildTarget buildTarget, string buildPath) { if (!InitialisationHelper.IsDevelopment() || !InitialisationHelper.IsDebugNotifications()) { return; } Debug.Log("Adding DDNA debug notification content extension into XCode Project"); PBXProject proj = new PBXProject(); string projPath = PBXProject.GetPBXProjectPath(buildPath); proj.ReadFromFile(projPath); #if UNITY_2019_3_OR_NEWER string mainTarget = proj.GetUnityFrameworkTargetGuid(); #else string mainTarget = proj.TargetGuidByName(PBXProject.GetUnityTargetName()); #endif string srcPath = Application.dataPath + "/DeltaDNA/Ads/Editor/iOS/NotificationContent/"; string destPath = buildPath + "/Notification Content/"; FileUtil.CopyFileOrDirectory(srcPath, destPath); string newTarget = proj.AddAppExtension(mainTarget, "Notification Content", PlayerSettings.applicationIdentifier + ".ddna-debug-ext", "Notification Content/Info.plist"); proj.AddFileToBuild(newTarget, proj.AddFile(destPath + "NotificationViewController.h", "Notification Content/NotificationViewController.h")); proj.AddFileToBuild(newTarget, proj.AddFile(destPath + "NotificationViewController.m", "Notification Content/NotificationViewController.m")); proj.AddFileToBuild(newTarget, proj.AddFile(destPath + "Info.plist", "Notification Content/Info.plist")); proj.AddFileToBuild(newTarget, proj.AddFile(destPath + "Base.lproj/MainInterface.storyboard", "Notification Content/MainInterface.storyboard")); proj.AddFrameworkToProject(newTarget, "UserNotificationsUI.framework", true); proj.AddFrameworkToProject(newTarget, "UserNotifications.framework", true); // link in the code from the Pods library string podPath = buildPath + "/Pods/DeltaDNADebug/DeltaDNADebug/"; proj.AddFileToBuild(newTarget, proj.AddFile(podPath + "Classes/DDNADebugNotificationViewController.h", "Notification Content/DDNADebugNotificationViewController.h")); proj.AddFileToBuild(newTarget, proj.AddFile(podPath + "Classes/DDNADebugNotificationViewController.m", "Notification Content/DDNADebugNotificationViewController.m")); proj.AddFileToBuild(newTarget, proj.AddFile(podPath + "Classes/DDNADebugContentViewController.h", "Notification Content/DDNADebugContentViewController.h")); proj.AddFileToBuild(newTarget, proj.AddFile(podPath + "Classes/DDNADebugContentViewController.m", "Notification Content/DDNADebugContentViewController.m")); proj.AddFileToBuild(newTarget, proj.AddFile(podPath + "Assets/DebugInterface.storyboard", "Notification Content/DebugInterface.storyboard")); proj.SetCompileFlagsForFile(newTarget, proj.FindFileGuidByProjectPath("Notification Content/DDNADebugContentViewController.m"), new List <string> { "-fobjc-arc" }); proj.SetTeamId(newTarget, PlayerSettings.iOS.appleDeveloperTeamID); proj.SetBuildProperty(newTarget, "IPHONEOS_DEPLOYMENT_TARGET", PlayerSettings.iOS.targetOSVersionString); proj.SetBuildProperty(newTarget, "ONLY_ACTIVE_ARCH", "NO"); proj.UpdateBuildProperty(newTarget, "ARCHS", new string[] { "armv7", "arm64" }, new string[] {}); // Update the search paths proj.SetBuildProperty(newTarget, "CLANG_ENABLE_MODULES", "YES"); proj.AddBuildProperty(newTarget, "OTHER_LDFLAGS", "$(inherited)"); proj.AddBuildProperty(newTarget, "OTHER_CFLAGS", "$(inherited)"); proj.AddBuildProperty(newTarget, "HEADER_SEARCH_PATHS", "$(inherited)"); proj.AddBuildProperty(newTarget, "HEADER_SEARCH_PATHS", "$(PROJECT_DIR)/Pods/Headers/Public"); proj.AddBuildProperty(newTarget, "FRAMEWORK_SEARCH_PATHS", "$(inherited)"); proj.AddBuildProperty(newTarget, "FRAMEWORK_SEARCH_PATHS", "$(PROJECT_DIR)/Frameworks"); proj.AddBuildProperty(newTarget, "LIBRARY_SEARCH_PATHS", "$(inherited)"); proj.AddBuildProperty(newTarget, "OTHER_LDFLAGS", "-ObjC"); // Add preprocessor defines string definesString = PlayerSettings.GetScriptingDefineSymbolsForGroup(EditorUserBuildSettings.selectedBuildTargetGroup); List <string> allDefines = definesString.Split(';').Where(i => i.Length > 0).Select(i => string.Format("{0}=1", i)).ToList(); allDefines.Add("$(inherited)"); allDefines.Reverse(); proj.UpdateBuildProperty(newTarget, "GCC_PREPROCESSOR_DEFINITIONS", allDefines, new string [] {}); proj.WriteToFile(projPath); }
internal override void ApplyChanges( bool enabled, IList <string> networks, bool debugNotifications) { lock (LOCK) { var config = Configuration(); config .Descendants("iosPod") .Remove(); if (enabled) { var packages = config.Descendants("iosPods").First(); packages.Add(new XElement( "iosPod", new object[] { new XAttribute( "name", "DeltaDNAAds/SmartAds"), new XAttribute( "version", VERSION), new XAttribute( "bitcodeEnabled", "true"), new XAttribute( "minTargetSdk", InitialisationHelper.IosMinTargetVersion()), new XElement("sources", sources) })); foreach (var network in networks) { packages.Add(new XElement( "iosPod", new object[] { new XAttribute( "name", "DeltaDNAAds/" + network), new XAttribute( "version", VERSION), new XAttribute( "bitcodeEnabled", "true"), new XAttribute( "minTargetSdk", InitialisationHelper.IosMinTargetVersion()), new XElement("sources", sources) })); } if (debugNotifications) { packages.Add(new XElement( "iosPod", new object[] { new XAttribute( "name", "DeltaDNADebug"), new XAttribute( "version", VERSION_DEBUG), new XAttribute( "bitcodeEnabled", "true"), new XAttribute( "minTargetSdk", InitialisationHelper.IosMinTargetVersion()), new XElement("sources", sources) })); } } config.Save(CONFIG); } }