Skip to main content
On this page

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.

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, -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 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

How 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.

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

Do 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