Skip to main content
On this page

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.

OptionDescription
-project / -workspace NAMEProject or workspace to build.
-scheme / -target NAME, -alltargetsScheme, target, or all targets to build.
-configuration NAMEBuild configuration.
-sdk SDK, -arch ARCH, -toolchain NAMESDK, architecture and toolchain.
-destination SPECDestination specifier, as comma-separated key=value pairs.
-xcconfig PATH, KEY=VALUEOverrides build settings.
-derivedDataPath PATH, -archivePath PATHBuild output directory and archive path.
-clonedSourcePackagesDirPath PATH, -resolvePackageDependenciesSwift package checkout directory, or resolves dependencies only.
-showBuildSettings, -showsdks, -showdestinations, -list, -versionPrints build settings, SDKs, destinations, targets and schemes, or the version. Add -json for JSON output.
-jobs N, -quiet, -verbose, -hideShellScriptEnvironment, -jsonParallelism 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 codeMeaning
64Usage error.
65Build failed, scheme error, or unsupported action.
66Input file not found.
> xcodebuild -workspace ios\MyApp.xcworkspace -scheme MyApp -configuration Debug -sdk iphoneos

xcrun

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.

OptionDescription
--sdk / -sdk NAMESDK 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-versionPrints the SDK path, version or build number.
--show-sdk-platform-path, --show-sdk-platform-versionPrints the platform directory or platform version.
--show-toolchain-pathPrints the toolchain directory.
-f, --find TOOLPrints 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-path

codesign

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