Building a Catalyst project from the command line with xcodebuild?

Not specifically Swift-related per se, but since it's impossible too get any answers on the regular Apple Developers forums :(, I figured I'd ask here:

I cannot see this documented anywhere — has anyone figured our how to use xcodebuild to build an iOS project for UIKIt for Mac (i.e. Catalyst) on the command line?

You can specify "-sdk iphoneos" vs "-sdk iphonesimulator" to toggle between those two targets, but "-sdk uikitformac" does not seem to work ("SDK not found"), despite Xcode itself using that nomenclature (e.g., it builds to a "Debug-uikitformac" folder, etc). i also tried different SDK values that might have made sense (such as "-sdk macabi"), but no avail.

Any ideas? The project I'm trying to build is a library, Mac is enabled in Xcode and the project can be built for UIKit for Mac fine inside Xcode — but I need to build it automatically from our build script, for (for now internal, of course) distribution.

1 Like

Catalyst is not a separate SDK. I'd try building against the macosx sdk, or iphoneos with the Mac as the destination.

I know under the hood, at the compiler level, xcodebuild is actually building against the macosx SDK, but it's using a target of x86_64-apple-ios13.0-macabi. But I'm not quite sure what the invocation is against xcodebuild.

(It's an old question, but I had to hunt around for the answer to this, so hopefully this is helpful to your or someone else in some way.)

Mac Catalyst support is implemented using -destination, like when building for a particular simulator. The invocation, based on the info in man xcodebuild (actually quite thorough!), is -destination 'platform=macOS,variant=Mac Catalyst'.

5 Likes

Thanx, that works (found the same solution on Stack Overflow a few days back).

Wonder how many different name strings for Catalyst Apple can come up with; we now have "UIKit for Mac", "uikitofrmac", "macabi"," iOSMac", "Catalyst" and "Mac Catalyst", depending on where you look. :joy:

3 Likes