I managed to figure it out based on a thread in the Unity forums.
Some of the build settings are stored in Library/EditorUserBuildSettings.asset
as a binary file (ignores the project settings for asset serialization as text).
The EditorUserBuildSettings
has a SetPlatformSettings
methods which allows you to change arbitrary properties in the build settings. Reverse engineering the editor build settings asset file and using this method allowed me to change this using the command line.
var createXCodeProject = EditorUserBuildSettings.GetPlatformSettings("OSXUniversal", "CreateXcodeProject");
Console.WriteLine($"[EditorUserBuildSettings] Create XCode project: {createXCodeProject}");
if (buildPath.EndsWith(".app"))
{
EditorUserBuildSettings.SetPlatformSettings("OSXUniversal", "CreateXcodeProject", "false");
}
else
{
EditorUserBuildSettings.SetPlatformSettings("OSXUniversal", "CreateXcodeProject", "true");
}