Skip to main content
On this page

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.

Build in VS Code and kxbuild build on the command line do the same thing. They compile, link, sign and package using the project's schemes, configurations and build settings. The default is Debug. A Release build of an iOS app writes an upload-ready package to build\<App>.ipa in the project folder. For every option, see the kxbuild command reference.

> kxbuild build .\MyApp.xcodeproj -s MyApp -c Release

Schemes, targets and configurations

You can build a .xcodeproj, a .xcworkspace or a folder with a Package.swift. Without a scheme or target, KXBuild builds the default scheme. The configuration defaults to the scheme's Run configuration, or Debug if there isn't one. To list a project's schemes, targets and bundle IDs, run kxbuild project info.

OptionVS CodeCommand line
ProjectThe startup project in the KXBuild viewFirst argument
Scheme / targetThe startup project's default scheme. With several targets you're asked to pick one. Build on a target node builds just that target.-s NAME / -t NAME. Add --ignoreDependence to skip dependencies.
ConfigurationThe Build configuration node in the KXBuild view or KXBuild: Select Build Configuration-c Debug|Release or a custom configuration name
SDK / architectureAlways iphoneos · arm64--sdk, --arch

Debug and Release

DebugRelease
Use forBreakpoint debugging on a deviceTestFlight, the App Store or Ad Hoc distribution
OptimizationOff, so breakpoints land where you expectOn, so breakpoints can jump around
CertificateUsually Apple DevelopmentApple Distribution for App Store submission
.ipaNot by default. Add --ipa PATH to get one.Written to build\<App>.ipa for iOS apps by default. --no-ipa turns it off.

Override build settings for one build

-D KEY=VALUE overrides any build setting for one build. You can repeat it, and it takes the same precedence as KEY=VALUE in xcodebuild. --xcconfig FILE applies a whole file at once.

> kxbuild build .\MyApp.xcodeproj -c Release -D CODE_SIGN_IDENTITY="Apple Distribution" -D DEVELOPMENT_TEAM=ABCDE12345
> kxbuild build .\MyApp.xcodeproj -D MARKETING_VERSION=1.2.0 -D CURRENT_PROJECT_VERSION=45

For permanent changes, edit the project file itself in the Project Settings Editor.

Build products

ProductLocationNotes
.app and intermediates~\DerivedData\<ProjectName>-<hash>\--derivedDataDir DIR changes the root. --clean empties it before building.
.ipa<project folder>\build\<App>.ipaWritten by default for iOS apps. Configurations other than Release are named <App>-<Config>.ipa. -o, --ipa PATH sets the path, and --no-ipa turns it off.
<App>.AppStoreInfo.plistNext to the .ipaThe upload descriptor for the -assetDescription option of command-line Transporter

In WSL, keep the project on the Linux side. Under /mnt/c, builds are an order of magnitude slower.

Simulator SDK

Use --sdk iphonesimulator to check that your code compiles for the simulator. Simulator builds are usually unsigned.

> kxbuild build .\MyApp.xcodeproj --sdk iphonesimulator -D CODE_SIGNING_ALLOWED=NO

Swift package dependencies

If the project uses Swift packages, they're resolved automatically before the build. To force a fresh resolve, like Xcode's Reset Package Caches, run

> kxbuild resolve .\MyApp.xcworkspace --force

In CI, add --only-use-versions-from-resolved-file to stick strictly to Package.resolved, and --skip-package-updates to avoid contacting remote repositories. Both build and resolve accept them.

Metal shaders

If the project contains .metal files, install Apple's Metal Developer Tools for Windows first. The download requires signing in with an Apple Account, so doctor can't install it for you. Download it once yourself. Open the Apple downloads page, sign in, download the latest Metal Developer Tools for Windows in the list and install it with the default options. See Metal developer tools for what's included. Then just build. KXBuild finds the tools on its own, with no PATH changes needed. Linux has no Metal compiler, so build these projects on Windows.

Install on your iPhone after building

> kxbuild build .\MyApp.xcodeproj --install

After a successful build, this installs the signed app on the connected iPhone. With several connected, it uses the first one. In VS Code the equivalent is Build & Run, which also attaches the debugger. See Run and debug.

Common recipes

GoalCommand
Install a Debug build on the iPhonekxbuild build .\MyApp.xcodeproj --install
Release .ipa for the App Storekxbuild build .\MyApp.xcodeproj -c Release
Debug .ipa at a path of your choice, to send to testerskxbuild build .\MyApp.xcodeproj --ipa D:\out\MyApp-dev.ipa
Build only one library targetkxbuild build .\MyApp.xcodeproj -t MyKit --ignoreDependence
Check that it compiles, without signingkxbuild build .\MyApp.xcodeproj -D CODE_SIGNING_ALLOWED=NO

For scripts and CI, see the kxbuild command reference.

Next steps