@@ -843,25 +843,41 @@ public static void SettingsDialog() {
843843 /// </summary>
844844 internal static bool MultipleXcodeTargetsSupported {
845845 get {
846- return typeof ( UnityEditor . iOS . Xcode . PBXProject ) . GetMethod (
847- "GetUnityMainTargetGuid" , Type . EmptyTypes ) != null ;
846+ try {
847+ return MultipleXcodeTargetsSupportedInternal ( ) ;
848+ } catch ( Exception e ) {
849+ return false ;
850+ }
848851 }
849852 }
850853
854+ private static bool MultipleXcodeTargetsSupportedInternal ( ) {
855+ return typeof ( UnityEditor . iOS . Xcode . PBXProject ) . GetMethod (
856+ "GetUnityMainTargetGuid" , Type . EmptyTypes ) != null ;
857+ }
858+
851859 /// <summary>
852860 /// Name of the Xcode main target generated by Unity.
853861 /// </summary>
854862 public static string XcodeMainTargetName {
855863 get {
856- // NOTE: Unity-iPhone is hard coded in UnityEditor.iOS.Xcode.PBXProject and will no
857- // longer be exposed via GetUnityTargetName(). It hasn't changed in many years though
858- // so we'll use this constant as a relatively safe default.
859- return MultipleXcodeTargetsSupported ? "Unity-iPhone" :
860- ( string ) VersionHandler . InvokeStaticMethod ( typeof ( UnityEditor . iOS . Xcode . PBXProject ) ,
861- "GetUnityTargetName" , null ) ;
864+ try {
865+ return XcodeMainTargetNameInternal ( ) ;
866+ } catch ( Exception e ) {
867+ return "Unity-iPhone" ;
868+ }
862869 }
863870 }
864871
872+ private static string XcodeMainTargetNameInternal ( ) {
873+ // NOTE: Unity-iPhone is hard coded in UnityEditor.iOS.Xcode.PBXProject and will no
874+ // longer be exposed via GetUnityTargetName(). It hasn't changed in many years though
875+ // so we'll use this constant as a relatively safe default.
876+ return MultipleXcodeTargetsSupported ? "Unity-iPhone" :
877+ ( string ) VersionHandler . InvokeStaticMethod ( typeof ( UnityEditor . iOS . Xcode . PBXProject ) ,
878+ "GetUnityTargetName" , null ) ;
879+ }
880+
865881 /// <summary>
866882 /// Name of the Xcode UnityFramework target generated by Unity 2019.3+
867883 /// </summary>
0 commit comments