How do I specify to xcodebuild
(the command line tool) whether I want to build for the simulator or device?
In general, Xcode has to do tasks like preprocess source files and compile them by compiler, link source code by linker, copy and process resources like headers, asset catalogues and storyboards, And finally code sign and maybe even do some custom work in a shell script or a make file like building API documentation ...
Both ios-arm64-simulator and ios-x86_64-simulator represent two equivalent library definitions. Seeing these when trying to create an xcframework for Apple Silicon that supports Mac Catalyst and the iOS Simulator: Both ios-arm64-simulator and ios-x86_64-simulator represent two equivalent library definitions.
Open Xcode and click Menu > Xcode > Preferences > Select Components, and then choose the simulator version you want to download. When a simulator is opened from AppStudio, AppStudio Player automatically installs (if necessary) and opens in it.
To launch a Simulator without running an app Do one of the following: Choose Xcode > Open Developer Tool > Simulator. Control-click the Xcode icon in the Dock, and from the shortcut menu, choose Open Developer Tool > Simulator.
An Xcode build from the command line looks like:
xcodebuild -configuration ${BUILD_TYPE} -target ${TARGET_NAME} -arch ${CPU_ARCHITECTURE} -sdk ${SIMULATOR_OR_IOS_SDK}
BUILD_TYPE
is something like "Release" or "Debug" (those are the defaults, you may have added others to the project)
TARGET_NAME
is the name of the target you are building (by default the same name as your project)
CPU_ARCHITECTURE
is the CPU you are building for, one of:
i386, armv6, armv7
Use i386 for simulator builds, and use either armv6 or armv7 for device builds - note that some other devices cannot run armv7 code, so usually when building libraries it's a good idea to build all of these architectures and then glue them together using lipo
.
SIMULATOR_OR_IOS_SDK
is what you are looking for, it's either iphoneos
or iphonesimulator
. Those values use the latest version of the SDK that the installed Xcode supports, you can get a list of supported SDK's with:
xcodebuild -showsdks
Which returns a list like:
Mac OS X SDKs: Current Mac OS -sdk Mac OS X 10.6 -sdk macosx10.6 iOS SDKs: iOS 4.2 -sdk iphoneos4.2 iOS Simulator SDKs: Simulator - iOS 3.2 -sdk iphonesimulator3.2 Simulator - iOS 4.0 -sdk iphonesimulator4.0 Simulator - iOS 4.1 -sdk iphonesimulator4.1 Simulator - iOS 4.2 -sdk iphonesimulator4.2
xcodebuild
has more flags than that, but those are the ones you'd commonly use after using Xcode to set up the build properties. You don't have to use all of them, but it's probably a good idea to be clear about what you are building - otherwise I believe your last settings are used.
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