xcodebuild and xcrun compatibility
Which actions and options the bundled xcodebuild and xcrun support and which they don't, what the exit codes mean, and why React Native, Expo and Flutter scripts work unchanged.
Drop-in commands
On Windows and Linux, the bin folder of the install directory contains xcodebuild, xcrun and codesign, named the same as on macOS. When React Native, Expo, Flutter or Cordova build scripts call them, they run the KXBuild versions, so the scripts work unchanged. Your own scripts can use the macOS syntax too. On macOS, Xcode already ships these commands, so the KXBuild version is named kxcodebuild and leaves the system ones alone.
Compatibility covers the options that framework scripts commonly use. xcodebuild test and -exportArchive are not supported. Use kxdevice test to run tests and kxbuild build -c Release to produce an .ipa. For everyday builds, prefer kxbuild build. It has more options and clearer output.
xcodebuild
xcodebuild [-project X.xcodeproj | -workspace X.xcworkspace] [-scheme S | -target T | -alltargets] [-configuration C] [-sdk SDK] [-arch A] [KEY=VALUE]… [action]…
Supported actions are build (the default), clean, install, installhdrs, installapi, installsrc and archive.
| Option | Description |
|---|---|
| -project / -workspace NAME | Project or workspace to build. |
| -scheme / -target NAME, -alltargets | Scheme, target, or all targets to build. |
| -configuration NAME | Build configuration. |
| -sdk SDK, -arch ARCH, -toolchain NAME | SDK, architecture and toolchain. |
| -destination SPEC | Destination specifier, as comma-separated key=value pairs. |
| -xcconfig PATH, KEY=VALUE | Overrides build settings. |
| -derivedDataPath PATH, -archivePath PATH | Build output directory and archive path. |
| -clonedSourcePackagesDirPath PATH, -resolvePackageDependencies | Swift package checkout directory, or resolves dependencies only. |
| -showBuildSettings, -showsdks, -showdestinations, -list, -version | Prints build settings, SDKs, destinations, targets and schemes, or the version. Add -json for JSON output. |
| -jobs N, -quiet, -verbose, -hideShellScriptEnvironment, -json | Parallelism and output control. |
test, build-for-testing, test-without-building, analyze, docbuild, -exportArchive, -create-xcframework, localization import and export, and platform downloads are not supported and exit with code 65. Other xcodebuild options are accepted and ignored. archive assembles only a minimal, unsigned .xcarchive. To produce an .ipa for distribution, run a Release build with kxbuild build.
| Exit code | Meaning |
|---|---|
| 64 | Usage error. |
| 65 | Build failed, scheme error, or unsupported action. |
| 66 | Input file not found. |
> xcodebuild -workspace ios\MyApp.xcworkspace -scheme MyApp -configuration Debug -sdk iphoneosxcrun
xcrun [--sdk SDK] [--show-sdk-path | --show-sdk-version | … | -f TOOL | TOOL ARGS…]
Finds a tool in the SDK or toolchain and runs it. Framework scripts mostly use it to look up the SDK path and to call clang.
| Option | Description |
|---|---|
| --sdk / -sdk NAME | SDK to use: iphoneos, iphonesimulator or macosx, optionally with a version, or a path. Defaults to iphoneos outside macOS. |
| --show-sdk-path, --show-sdk-version, --show-sdk-build-version | Prints the SDK path, version or build number. |
| --show-sdk-platform-path, --show-sdk-platform-version | Prints the platform directory or platform version. |
| --show-toolchain-path | Prints the toolchain directory. |
| -f, --find TOOL | Prints the full path of a tool. |
| xcrun clang …, xcrun xcodebuild … | Runs a tool. For clang, adds the target triple, SDK root and linker flags that match -sdk and -arch. |
> xcrun --sdk iphoneos --show-sdk-pathcodesign
Signs code and verifies signatures, with the same options, output and exit codes as on macOS. Certificates come from the keychain folder. Builds sign automatically, so you rarely need to call it yourself.
Next steps
kxbuild command reference
Every kxbuild subcommand and option, including doctor, build, resolve, project, update and version.
Build and configure
Debug versus Release, choosing a scheme, target and configuration, overriding build settings, where build products go, when you get an .ipa and when Swift package dependencies resolve.