skip to Main Content

Recently I moved to using an M1 Mac Mini as a build machine for Unity IOS projects through Xcode.

Often I would use the Unity option to ‘Build and Run’ which would auto open Xcode and build the app – often this would select the first available device target. I can always select the iPhone to build to but it always reverts back to ‘My Mac’ build target when Xcode opens the project again despite the phone staying connected via USB.

This M1 Mac Mini seems to have ‘My Mac (Designed for iPad)’ as a build target for iPhone/iPad only apps (not mac build target) and Xcode automatically chooses to build for that target rather than the connected iPhone when Unity exports the build.

Is there a way to exclude that My Mac build target in Xcode or in the Xcode project? I only want to test on device and we are exporting as Device SDK not Simulator SDK for this reason.

3

Answers


  1. Chosen as BEST ANSWER

    From this forum post on Unity Forum post I made is an easy editor script fix

        #if UNITY_IOS
     
    using System;
    using System.IO;
    using UnityEditor;
    using UnityEditor.Callbacks;
    using UnityEditor.iOS.Xcode;
    using UnityEngine;
     
    public class iOSPostProccessorBuild
    {
        [PostProcessBuild(2000)]
        public static void OnPostProcessBuild(BuildTarget target, string path)
        {
            Debug.Log("iOSBuildPostProcess is now postprocessing iOS Project");
     
            var projectPath = PBXProject.GetPBXProjectPath(path);
     
            var project = new PBXProject();
            project.ReadFromFile(projectPath);
     
            var targetGuid = project.GetUnityMainTargetGuid();
     
            project.SetBuildProperty(targetGuid, "SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD", "NO");
     
            try
            {
                var projectInString = File.ReadAllText(projectPath);
                projectInString = projectInString.Replace("SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = YES;",
                    $"SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO;");
                File.WriteAllText(projectPath, projectInString);
            }
            catch (Exception e)
            {
                Debug.LogException(e);
            }
     
            project.WriteToFile(projectPath);
        }
    }
     
    #endif
    

  2. Try to connect your device to Xcode via USB to see if it detects your device, once Xcode recognizes your device select it and build your project on that device of yours.

    Login or Signup to reply.
  3. You can hide it by setting this option to No
    enter image description here

    After that, choose "Append" instead of "Replace" every time you "Build and Run" your Unity project. If you choose "Replace", Unity will erase Xcode settings and you will need to set it again.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search