@@ -808,6 +808,29 @@ internal static bool MultipleXcodeTargetsSupported {
808
808
}
809
809
}
810
810
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
+
811
834
/// <summary>
812
835
/// Initialize the TARGET_NAME property.
813
836
/// This will be "Unity-iPhone" in versions of Unity (2019.3+) that added support for using
@@ -818,9 +841,7 @@ private static string InitializeTargetName() {
818
841
// NOTE: Unity-iPhone is hard coded in UnityEditor.iOS.Xcode.PBXProject and will soon longer
819
842
// be exposed via GetUnityTargetName(). It hasn't changed in many years though so we'll use
820
843
// 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 ;
824
845
return TARGET_NAME ;
825
846
}
826
847
@@ -1802,7 +1823,7 @@ public static IEnumerable<string> XcodeTargetNames {
1802
1823
get {
1803
1824
// Return hard coded names in the UnityEditor.iOS.Xcode.PBXProject DLL.
1804
1825
return MultipleXcodeTargetsSupported ?
1805
- new List < string > ( ) { "UnityFramework" } :
1826
+ new List < string > ( ) { XcodeUnityFrameworkTargetName } :
1806
1827
new List < string > ( ) { InitializeTargetName ( ) } ;
1807
1828
}
1808
1829
}
@@ -1954,7 +1975,7 @@ private static void ParseUnityDeps(string unityPodfilePath) {
1954
1975
continue ;
1955
1976
}
1956
1977
// TODO: Properly support multiple targets.
1957
- if ( line . StartsWith ( "target 'Unity-iPhone ' do" ) ) {
1978
+ if ( line . StartsWith ( String . Format ( "target '{0} ' do" , XcodeMainTargetName ) ) ) {
1958
1979
capturingPodsDepth ++ ;
1959
1980
continue ;
1960
1981
}
@@ -2074,7 +2095,7 @@ public static void GenPodfile(BuildTarget buildTarget,
2074
2095
}
2075
2096
2076
2097
if ( MultipleXcodeTargetsSupported && PodfileAlwaysAddMainTarget ) {
2077
- file . WriteLine ( String . Format ( "target '{0}' do" , "Unity-iPhone" ) ) ;
2098
+ file . WriteLine ( String . Format ( "target '{0}' do" , XcodeMainTargetName ) ) ;
2078
2099
bool allowPodsInMultipleTargets = PodfileAllowPodsInMultipleTargets ;
2079
2100
int podAdded = 0 ;
2080
2101
foreach ( var pod in pods . Values ) {
0 commit comments