using UnityEngine; using UnityEditor; using UnityEditor.Callbacks; using System.IO; using System.Collections.Generic; #if UNITY_IOS using UnityEditor.iOS.Xcode; #endif public class BuildPostProcessor : MonoBehaviour { #if RND_TENJIN [PostProcessBuild] public static void OnPostprocessBuild(BuildTarget buildTarget, string path) { if (buildTarget == BuildTarget.iOS) BuildiOS(path: path); else if (buildTarget == BuildTarget.Android) BuildAndroid(path: path); } private static void BuildAndroid(string path = "") { Log.Debug("TenjinSDK: Starting Android Build"); } private static void BuildiOS(string path = "") { #if UNITY_IOS Log.Debug("TenjinSDK: Starting iOS Build"); string projectPath = path + "/Unity-iPhone.xcodeproj/project.pbxproj"; var project = new PBXProject(); project.ReadFromFile(projectPath); #if UNITY_2019_3_OR_NEWER string buildTarget = project.GetUnityFrameworkTargetGuid(); #else string buildTarget = project.TargetGuidByName("Unity-iPhone"); #endif var frameworks = new List(); frameworks.Add("AdSupport.framework"); frameworks.Add("AppTrackingTransparency.framework"); frameworks.Add("iAd.framework"); frameworks.Add("StoreKit.framework"); foreach (string framework in frameworks) { Log.Debug("TenjinSDK: Adding framework: " + framework); project.AddFrameworkToProject(buildTarget, framework, true); } Log.Debug("TenjinSDK: Adding -ObjC flag to other linker flags (OTHER_LDFLAGS)"); project.AddBuildProperty(buildTarget, "OTHER_LDFLAGS", "-ObjC"); File.WriteAllText(projectPath, project.WriteToString()); #endif } #endif }