@@ -10,43 +10,39 @@ public class MyBuildPostprocessor
1010 [ PostProcessBuild ]
1111 public static void OnPostprocessBuild ( BuildTarget target , string pathToBuiltProject )
1212 {
13- if ( target == BuildTarget . iOS )
13+ if ( target == BuildTarget . iOS || target == BuildTarget . tvOS )
1414 OnPostprocessBuildIOS ( pathToBuiltProject ) ;
1515 }
1616
1717 private static void OnPostprocessBuildIOS ( string pathToBuiltProject )
1818 {
19- // We use UnityEditor.iOS.Xcode API which only exists in iOS editor module
20- #if UNITY_IOS
21-
19+ // We use UnityEditor.iOS.Xcode API which only exists in iOS editor module
20+ #if UNITY_IOS || UNITY_TVOS
2221 string projPath = pathToBuiltProject + "/Unity-iPhone.xcodeproj/project.pbxproj" ;
2322
2423 UnityEditor . iOS . Xcode . PBXProject proj = new UnityEditor . iOS . Xcode . PBXProject ( ) ;
2524 proj . ReadFromString ( File . ReadAllText ( projPath ) ) ;
26- string target = proj . TargetGuidByName ( "Unity-iPhone" ) ;
2725
28- Directory . CreateDirectory ( Path . Combine ( pathToBuiltProject , "Libraries/Unity" ) ) ;
26+ #if UNITY_2019_3_OR_NEWER
27+ string target = proj . GetUnityFrameworkTargetGuid ( ) ;
28+ #else
29+ string target = proj . TargetGuidByName ( "Unity-iPhone" ) ;
30+ #endif
2931
30- string [ ] filesToCopy = new string [ ]
31- {
32- "PlatformBase.h" ,
33- "RenderAPI_Metal.mm" ,
34- "RenderAPI_OpenGLCoreES.cpp" ,
35- "RenderAPI.cpp" ,
36- "RenderAPI.h" ,
37- "RenderingPlugin.cpp" ,
32+ string [ ] filesToCopy = new string [ ] {
33+ "PlatformBase.h" , "RenderingPlugin.cpp" ,
34+ "RenderAPI_Metal.mm" , "RenderAPI_OpenGLCoreES.cpp" , "RenderAPI.cpp" , "RenderAPI.h" ,
3835 } ;
39-
4036 for ( int i = 0 ; i < filesToCopy . Length ; ++ i )
4137 {
42- var srcPath = Path . Combine ( "../PluginSource/source" , filesToCopy [ i ] ) ;
43- var dstLocalPath = "Libraries/" + filesToCopy [ i ] ;
44- var dstPath = Path . Combine ( pathToBuiltProject , dstLocalPath ) ;
38+ string srcPath = Path . Combine ( "../PluginSource/source" , filesToCopy [ i ] ) ;
39+ string dstLocalPath = "Libraries/" + filesToCopy [ i ] ;
40+ string dstPath = Path . Combine ( pathToBuiltProject , dstLocalPath ) ;
4541 File . Copy ( srcPath , dstPath , true ) ;
4642 proj . AddFileToBuild ( target , proj . AddFile ( dstLocalPath , dstLocalPath ) ) ;
4743 }
4844
4945 File . WriteAllText ( projPath , proj . WriteToString ( ) ) ;
50- #endif // #if UNITY_IOS
46+ #endif
5147 }
5248}
0 commit comments