Yandex Mobile Ads
Loading...
Searching...
No Matches
PostprocessBuildPlayerYandexMobileAds.cs
Go to the documentation of this file.
1/*
2 * This file is a part of the Yandex Advertising Network
3 *
4 * Version for Unity (C) 2023 YANDEX
5 *
6 * You may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at https://legal.yandex.com/partner_ch/
8 */
9
10using UnityEditor;
11using UnityEditor.Callbacks;
12#if UNITY_IOS
13using UnityEditor.iOS.Xcode;
14#endif
15using System.IO;
16using System.Collections;
17
22
23#if UNITY_IOS
24public class PostprocessBuildPlayerYandexMobileAds
25{
26 private static readonly string[] StrongFrameworks = {
27 "QuartzCore",
28 "AVFoundation",
29 "CoreImage",
30 "CoreMedia",
31 "SystemConfiguration",
32 "UIKit",
33 "Foundation",
34 "CoreTelephony",
35 "CoreLocation",
36 "CoreGraphics",
37 "AdSupport",
38 "Security",
39 "StoreKit"
40 };
41
42 private static readonly string[] WeakFrameworks = {
43 "SafariServices",
44 "WebKit"
45 };
46
47 private static readonly string[] Libraries = {
48 "z",
49 "sqlite3",
50 "c++",
51 "xml2"
52 };
53
54 private static readonly string[] LDFlags = {
55 "-ObjC"
56 };
57
58 [PostProcessBuild]
59 public static void OnPostprocessBuild (BuildTarget buildTarget, string path)
60 {
61#if UNITY_5 || UNITY_2017_1_OR_NEWER
62 var expectedTarget = BuildTarget.iOS;
63#else
64 var expectedTarget = BuildTarget.iPhone;
65#endif
66 if (buildTarget == expectedTarget) {
67 var projectPath = path + "/Unity-iPhone.xcodeproj/project.pbxproj";
68
69 var project = new PBXProject ();
70 project.ReadFromString (File.ReadAllText (projectPath));
71
72#if UNITY_2020_1_OR_NEWER
73 var target = project.GetUnityFrameworkTargetGuid ();
74#else
75 var target = project.TargetGuidByName ("Unity-iPhone");
76#endif
77
78 foreach (var frameworkName in StrongFrameworks) {
79 project.AddFrameworkToProject (target, frameworkName + ".framework", false);
80 }
81 foreach (var frameworkName in WeakFrameworks) {
82 project.AddFrameworkToProject (target, frameworkName + ".framework", true);
83 }
84 foreach (var flag in LDFlags) {
85 project.AddBuildProperty (target, "OTHER_LDFLAGS", flag);
86 }
87 foreach (var libraryName in Libraries) {
88 project.AddBuildProperty (target, "OTHER_LDFLAGS", "-l" + libraryName);
89 }
90
91 File.WriteAllText (projectPath, project.WriteToString ());
92 }
93 }
94}
95#endif