xcodebuild and xcrun on Windows and Linux: Compatibility Guide
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.
Last updated
You can run xcodebuild on Windows once KXBuild is installed: the bin folder of the install directory holds xcodebuild, xcrun and codesign under the same names as on macOS, so React Native, Expo, Flutter and Cordova build scripts run unchanged. Common actions such as build, clean and archive, plus the options framework scripts use, are supported. test and -exportArchive are not and exit with code 65, so use kxdevice test and kxbuild build instead.
Which program runs when a build script calls xcodebuild?
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. After archive, export the .ipa with -exportArchive, or do it in one step with kxbuild build -c Release --export app-store. xcodebuild test is not supported; use kxdevice test to run tests. For everyday builds, prefer kxbuild build. It has more options and clearer output.
Which xcodebuild actions and options work on Windows?
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, -create-xcframework, localization import and export, and platform downloads are not supported and exit with code 65. Other xcodebuild options are accepted and ignored. -exportArchive signs the archive again for the method in ExportOptions.plist (app-store-connect, release-testing, enterprise, debugging, or the older app-store, ad-hoc, development), using its teamID and provisioningProfiles and the certificates and profiles in your keychain folder, and writes the .ipa to -exportPath. destination supports export only; upload the .ipa with an App Store upload tool. If -exportArchive fails, read the error: line; usually the keychain folder lacks a profile for that distribution method or its .p12.
| 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 iphoneosHow do I find the SDK path and call clang with 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.
| 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-pathDo I need to call codesign myself?
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.
With xcodebuild on Windows, a framework's own iOS build flow runs as is, for example when you build React Native iOS apps on Windows. For everyday builds of your own projects, kxbuild build is still the better choice.
Next steps
kxbuild command reference
Every kxbuild subcommand and option, including doctor, build, run, test, project, license, mcp 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.