'How to hide/disable 'My Mac (Designed for iPad)' Build Target - Xcode 13
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.
Solution 1:[1]
You can hide it by setting this option to No
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.
Solution 2:[2]
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
Solution 3:[3]
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.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | |
Solution 2 | ROBYER1 |
Solution 3 | Felipe Vallejo |