1- using System . Collections ;
2- using System . Collections . Generic ;
3- using UnityEngine ;
1+ #if UNITY_IOS
42using UnityEditor ;
53using UnityEditor . Callbacks ;
64using UnityEditor . iOS . Xcode ;
7- using System . Diagnostics ;
8-
95using System . IO ;
10- using System . Linq ;
116using UnityEditor . iOS . Xcode . Extensions ;
12- using Debug = UnityEngine . Debug ;
137
148public static class CMPPostProcessBuild
159{
@@ -23,36 +17,64 @@ public static void OnPostProcessBuild(BuildTarget buildTarget, string buildPath)
2317 PBXProject pbxProject = new PBXProject ( ) ;
2418 string projPath = buildPath + "/Unity-Iphone.xcodeproj/project.pbxproj" ;
2519 pbxProject . ReadFromFile ( projPath ) ;
20+ string unityProjectGuid = pbxProject . ProjectGuid ( ) ;
2621 string unityMainTargetGuid = pbxProject . GetUnityMainTargetGuid ( ) ;
27-
28- ConfigureFrameworks ( pbxProject , unityMainTargetGuid ) ;
22+
23+ pbxProject . AddBuildProperty ( unityMainTargetGuid , "LIBRARY_SEARCH_PATHS" , "\" $(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME)\" \" /usr/lib/swift\" " ) ;
24+ pbxProject . AddBuildProperty ( unityProjectGuid , "ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES" , "YES" ) ;
25+
26+ ConfigureFrameworks ( pbxProject , unityProjectGuid ) ;
2927 TieBridgingHeader ( pbxProject , unityMainTargetGuid ) ;
3028 EnableCppModules ( pbxProject ) ;
3129 EnableObjectiveCExceptions ( pbxProject ) ;
32- //LinkBinaryWithLibraries(pbxProject, unityMainGUID);
33- // EnableSwift(pbxProject, targetGuid);
30+ EnableBitcode ( pbxProject , unityProjectGuid , false ) ;
31+ // EnableBitcode(pbxProject, unityMainTargetGuid, false);
32+
33+ // LinkBinaryWithLibraries(pbxProject, unityMainGUID);
34+ // LinkBinaryWithLibraries(pbxProject,unityMainTargetGuid, "libswiftWebKit.tbd");
35+ // EnableSwift(pbxProject, unityProjectGuid);
3436
3537 pbxProject . WriteToFile ( projPath ) ;
38+
39+ string plistPath = buildPath + "/Info.plist" ;
40+ AddParameterToInfoPlist ( plistPath ) ;
3641 }
3742 }
3843
44+ static void AddParameterToInfoPlist ( string plistPath )
45+ {
46+ PlistDocument plist = new PlistDocument ( ) ;
47+ plist . ReadFromString ( File . ReadAllText ( plistPath ) ) ;
48+ PlistElementDict rootDict = plist . root ;
49+
50+ // var buildKey = "Privacy - Tracking Usage Description";
51+ var buildKey = "NSUserTrackingUsageDescription" ;
52+ rootDict . SetString ( buildKey , "This identifier will be used to deliver personalized ads to you." ) ;
53+
54+ File . WriteAllText ( plistPath , plist . WriteToString ( ) ) ;
55+ }
56+
3957 static void ConfigureFrameworks ( PBXProject pbxProject , string targetGuid )
4058 {
41- pbxProject . AddBuildProperty ( targetGuid , "LD_RUNPATH_SEARCH_PATHS" , "@executable_path/Frameworks $(PROJECT_DIR) /lib/$(CONFIGURATION) $(inherited) " ) ;
42- pbxProject . AddBuildProperty ( targetGuid , "FRAMERWORK_SEARCH_PATHS" ,
59+ pbxProject . AddBuildProperty ( targetGuid , "LD_RUNPATH_SEARCH_PATHS" , "/usr /lib/swift " ) ;
60+ /* pbxProject.AddBuildProperty(targetGuid, "FRAMERWORK_SEARCH_PATHS",
4361 "$(inherited) $(PROJECT_DIR) $(PROJECT_DIR)/Frameworks");
4462 pbxProject.AddBuildProperty(targetGuid, "DYLIB_INSTALL_NAME_BASE", "@rpath");
4563 pbxProject.AddBuildProperty(targetGuid, "LD_DYLIB_INSTALL_NAME",
46- "@executable_path/../Frameworks/$(EXECUTABLE_PATH)" ) ;
64+ "@executable_path/../Frameworks/$(EXECUTABLE_PATH)");*/
4765 }
4866
4967 static void TieBridgingHeader ( PBXProject pbxProject , string targetGuid )
5068 {
51- pbxProject . SetBuildProperty ( targetGuid , "ENABLE_BITCODE" , "NO" ) ;
5269 pbxProject . SetBuildProperty ( targetGuid , "SWIFT_OBJC_BRIDGING_HEADER" , "Libraries/Plugins/iOS/Source/UnityPlugin-Bridging-Header.h" ) ;
5370 pbxProject . SetBuildProperty ( targetGuid , "SWIFT_OBJC_INTERFACE_HEADER_NAME" , "UnityController.h" ) ;
5471 }
55-
72+
73+ private static void EnableBitcode ( PBXProject pbxProject , string targetGuid , bool enabled )
74+ {
75+ pbxProject . SetBuildProperty ( targetGuid , "ENABLE_BITCODE" , enabled ? "YES" : "NO" ) ;
76+ }
77+
5678 static void EnableCppModules ( PBXProject pbxProject )
5779 {
5880 pbxProject . AddBuildProperty ( pbxProject . GetUnityMainTargetGuid ( ) , "CLANG_ENABLE_MODULES" , "YES" ) ;
@@ -78,4 +100,5 @@ static void EnableSwift(PBXProject pbxProject, string targetGuid)
78100 pbxProject . AddBuildProperty ( targetGuid , "COREML_CODEGEN_LANGUAGE" , "Swift" ) ;
79101 pbxProject . AddBuildProperty ( targetGuid , "ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES" , "YES" ) ;
80102 }
81- }
103+ }
104+ #endif
0 commit comments