@@ -808,6 +808,29 @@ internal static bool MultipleXcodeTargetsSupported {
808808 }
809809 }
810810
811+ /// <summary>
812+ /// Name of the Xcode main target generated by Unity.
813+ /// </summary>
814+ public static string XcodeMainTargetName {
815+ get {
816+ // NOTE: Unity-iPhone is hard coded in UnityEditor.iOS.Xcode.PBXProject and will no
817+ // longer be exposed via GetUnityTargetName(). It hasn't changed in many years though
818+ // so we'll use this constant as a relatively safe default.
819+ return MultipleXcodeTargetsSupported ? "Unity-iPhone" :
820+ ( string ) VersionHandler . InvokeStaticMethod ( typeof ( UnityEditor . iOS . Xcode . PBXProject ) ,
821+ "GetUnityTargetName" , null ) ;
822+ }
823+ }
824+
825+ /// <summary>
826+ /// Name of the Xcode UnityFramework target generated by Unity 2019.3+
827+ /// </summary>
828+ public static string XcodeUnityFrameworkTargetName {
829+ get {
830+ return "UnityFramework" ;
831+ }
832+ }
833+
811834 /// <summary>
812835 /// Initialize the TARGET_NAME property.
813836 /// This will be "Unity-iPhone" in versions of Unity (2019.3+) that added support for using
@@ -818,9 +841,7 @@ private static string InitializeTargetName() {
818841 // NOTE: Unity-iPhone is hard coded in UnityEditor.iOS.Xcode.PBXProject and will soon longer
819842 // be exposed via GetUnityTargetName(). It hasn't changed in many years though so we'll use
820843 // this constant as a relatively safe default for users of the TARGET_NAME variable.
821- TARGET_NAME = MultipleXcodeTargetsSupported ? "Unity-iPhone" :
822- ( string ) VersionHandler . InvokeStaticMethod ( typeof ( UnityEditor . iOS . Xcode . PBXProject ) ,
823- "GetUnityTargetName" , null ) ;
844+ TARGET_NAME = XcodeMainTargetName ;
824845 return TARGET_NAME ;
825846 }
826847
@@ -1802,7 +1823,7 @@ public static IEnumerable<string> XcodeTargetNames {
18021823 get {
18031824 // Return hard coded names in the UnityEditor.iOS.Xcode.PBXProject DLL.
18041825 return MultipleXcodeTargetsSupported ?
1805- new List < string > ( ) { "UnityFramework" } :
1826+ new List < string > ( ) { XcodeUnityFrameworkTargetName } :
18061827 new List < string > ( ) { InitializeTargetName ( ) } ;
18071828 }
18081829 }
@@ -1954,7 +1975,7 @@ private static void ParseUnityDeps(string unityPodfilePath) {
19541975 continue ;
19551976 }
19561977 // TODO: Properly support multiple targets.
1957- if ( line . StartsWith ( "target 'Unity-iPhone ' do" ) ) {
1978+ if ( line . StartsWith ( String . Format ( "target '{0} ' do" , XcodeMainTargetName ) ) ) {
19581979 capturingPodsDepth ++ ;
19591980 continue ;
19601981 }
@@ -2074,7 +2095,7 @@ public static void GenPodfile(BuildTarget buildTarget,
20742095 }
20752096
20762097 if ( MultipleXcodeTargetsSupported && PodfileAlwaysAddMainTarget ) {
2077- file . WriteLine ( String . Format ( "target '{0}' do" , "Unity-iPhone" ) ) ;
2098+ file . WriteLine ( String . Format ( "target '{0}' do" , XcodeMainTargetName ) ) ;
20782099 bool allowPodsInMultipleTargets = PodfileAllowPodsInMultipleTargets ;
20792100 int podAdded = 0 ;
20802101 foreach ( var pod in pods . Values ) {
0 commit comments