How to hide/disable 'My Mac (Designed for iPad)' Build Target - Xcode 13 on M1 Mac

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.

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 Likes

Same problem (M1 Air), so annoying. I need to manually set my iPhone and run from xcode.

I got the answer on my Stack overflow post here: ios - How to hide/disable 'My Mac (Designed for iPad)' Build Target - Xcode 13 - Stack Overflow

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.

3 Likes

Also make sure to do that for each of the targets in that list

2 Likes

I’ve missed that I need to do it for all targets. Thanks!

1 Like

Hi!

My idea is to use the following post process script for iOS, so you can don’t mind replace/append step anymore.

#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 Likes

I was thinking of writing this just never got round to it, thanks so much for sharing!

1 Like

@AytoMaximo you are a god

1 Like

Hi, thanks for your awesome code. May I ask what’s the purpose of the following code:

        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);
        }

It seems like project.WriteToFile(projectPath); has done the same thing here.

Hi! You’re free to try the build without this code. Honestly, I’ve found this block of code somewhere else for another Info.plist parameter, so I just fixed it for our case.

Using the script provided by @AytoMaximo causes the Unity editor to become unresponsive and will not complete the build process. I’m using Unity editor 2021.3.5f1. Does anyone else see this or have any additional solutions?