11using UnityEditor.Callbacks;
13using UnityEditor.iOS.Xcode;
16using System.Collections;
24public class PostprocessBuildPlayerYandexMobileAds
26 private static readonly
string[] StrongFrameworks = {
31 "SystemConfiguration",
42 private static readonly
string[] WeakFrameworks = {
47 private static readonly
string[] Libraries = {
54 private static readonly
string[] LDFlags = {
59 public static void OnPostprocessBuild (BuildTarget buildTarget,
string path)
61#if UNITY_5 || UNITY_2017_1_OR_NEWER
62 var expectedTarget = BuildTarget.iOS;
64 var expectedTarget = BuildTarget.iPhone;
66 if (buildTarget == expectedTarget) {
67 var projectPath = path +
"/Unity-iPhone.xcodeproj/project.pbxproj";
69 var project =
new PBXProject ();
70 project.ReadFromString (File.ReadAllText (projectPath));
72#if UNITY_2020_1_OR_NEWER
73 var target = project.GetUnityFrameworkTargetGuid ();
75 var target = project.TargetGuidByName (
"Unity-iPhone");
78 foreach (var frameworkName
in StrongFrameworks) {
79 project.AddFrameworkToProject (target, frameworkName +
".framework",
false);
81 foreach (var frameworkName
in WeakFrameworks) {
82 project.AddFrameworkToProject (target, frameworkName +
".framework",
true);
84 foreach (var flag
in LDFlags) {
85 project.AddBuildProperty (target,
"OTHER_LDFLAGS", flag);
87 foreach (var libraryName
in Libraries) {
88 project.AddBuildProperty (target,
"OTHER_LDFLAGS",
"-l" + libraryName);
91 File.WriteAllText (projectPath, project.WriteToString ());