I cannot see this documented anywhere — has anyine figured our how to use xcodebuild to build a propject for UIKIt for Mac (i.e. Catalyst)?
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.
Suggestions?
The Command Line Tools Package is a small self-contained package available for download separately from Xcode and that allows you to do command line development in macOS. It consists of the macOS SDK and command-line tools such as Clang, which are installed in the /Library/Developer/CommandLineTools directory.
Right click the executable in your Xcode project and pick "Get Info". Then pick the "arguments" tab and you can set arguments to pass when you run or debug your program from inside Xcode. Go to the Product menu, select "Edit Scheme", then select the arguments tab and add the arguments there.
go to the 'Info' tab and in a menu 'Executable' choose 'Other...' in file window go to search input field and type 'terminal' and click on its icon when you find it. Now you should see 'Terminal. app' in 'Executable' field.
Add script file to your projects folder:
SCHEME=TestFramework \
ARCHS=~/Documents/Archives \
SCHEME
is the name of build scheme in Xcode.
Lets build macCatalyst archive:
#----- Make macCatalyst archive
xcodebuild archive \
-scheme $SCHEME \
-archivePath $ARCHS/macCatalyst.xcarchive \
-sdk macosx \
SKIP_INSTALL=NO BUILD_LIBRARIES_FOR_DISTRIBUTION=YES SUPPORTS_MACCATALYST=YES
Also you can add other platforms like iOS device or Simulator:
#----- Make iOS Simulator archive
xcodebuild archive \
-scheme $SCHEME \
-archivePath $ARCHS/simulator.xcarchive \
-sdk iphonesimulator \
SKIP_INSTALL=NO BUILD_LIBRARIES_FOR_DISTRIBUTION=YES
#----- Make iOS device archive
xcodebuild archive \
-scheme $SCHEME \
-archivePath $ARCHS/iosdevice.xcarchive \
-sdk iphoneos \
SKIP_INSTALL=NO BUILD_LIBRARIES_FOR_DISTRIBUTION=YES
To include everything in XCFramework use:
#----- Make XCFramework
xcodebuild -create-xcframework \
-framework $ARCHS/simulator.xcarchive/Products/Library/Frameworks/$SCHEME.framework \
-framework $ARCHS/iosdevice.xcarchive/Products/Library/Frameworks/$SCHEME.framework \
-framework $ARCHS/macCatalyst.xcarchive/Products/Library/Frameworks/$SCHEME.framework \
-output ~/Documents/$SCHEME.xcframework
After running you will find your XCFramework in your Documents folder.
Try:
xcodebuild -configuration "Debug" ARCHS="x86_64h" \
-destination 'platform=macOS,variant=Mac Catalyst' \
-project "MyApp.xcodeproj"
(note the extra 'h' on the architecture)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With