Skip to main content
On this page

kxbuild command reference

Every kxbuild subcommand and option, including doctor, build, resolve, project, update and version.

Usage: kxbuild <command> [options]. kxbuild handles projects and builds. Device operations belong to kxdevice. Every command accepts --help. The global --json option prints machine-readable JSON for scripts and the extension. Leave it off when troubleshooting, because error details appear only in the normal output.

> kxbuild version

Commands

CommandDescription
doctor [project]Checks and fixes the development environment. With a project path, also prepares that project.
build <project>Builds and packages a project, and optionally installs it on a device.
resolve <project>Resolves Swift package dependencies.
project …Inspects, creates, edits and converts projects.
updateUpdates kxbuild to the latest version, then runs doctor.
versionPrints version information.

doctor

kxbuild doctor [project] [-v]

Checks the development environment and fixes what it can. On Windows, it also turns on Developer Mode and long path support. With a project path, it detects the project type and prepares the project. Flutter, React Native, Expo, Kotlin Multiplatform and cocos2d-x projects need this before their first build.

Run doctor after you install or update, and whenever a build or debug session fails. It fixes most environment problems on its own. If something still fails, see Troubleshooting.

OptionDescription
-v, --verboseShows every step and subprocess output. Use it when troubleshooting.
> kxbuild doctor
> kxbuild doctor D:\projects\my_flutter_app -v

build

kxbuild build <project.xcodeproj | project.xcworkspace | package dir> [options]

Builds and packages an Xcode project, a workspace, or a directory that contains Package.swift. Without a scheme or target, builds the default one. For projects that use CocoaPods, build the .xcworkspace. For common tasks, see Build and configure.

What to build

OptionDescription
-s, --scheme NAMEBuilds the scheme with this name.
-t, --target NAMEBuilds the target with this name.
-c, --config NAMEBuild configuration. Defaults to the scheme's run configuration, or Debug when there is no scheme.
--sdk NAMESDK to build against: iphoneos, iphonesimulator or macosx.
--arch ARCHBuilds only this architecture, arm64 or x86_64.
--toolchain NAMEToolchain to build with, by name or identifier.
--ignoreDependenceBuilds only the named targets and skips their dependencies.

Build settings

OptionDescription
-D, --setting KEY=VALUEOverrides a build setting. Repeatable. Same precedence as xcodebuild KEY=VALUE.
--xcconfig PATHApplies the settings in an .xcconfig file, like xcodebuild -xcconfig.

Output and packaging

OptionDescription
--derivedDataDir DIRRoot directory for build output. Defaults to ~/DerivedData. Each project gets its own <name>-<hash> folder inside.
--cleanRemoves the build output directory before building.
-o, --ipa PATHPackages the built iOS app into an .ipa at PATH. Without it, the .ipa goes to <project dir>\build\<App>.ipa for Release, or <App>-<Config>.ipa for other configurations.
--no-ipaSkips packaging the .ipa.
-i, --installOn success, installs the signed app on the connected device. Same as running kxdevice install afterwards.
--emit-commands-onlyWrites only compile_commands.json for editor code completion. Doesn't compile, link or sign.

Performance and diagnostics

OptionDescription
-j, --jobs NNumber of tasks to run in parallel. Defaults to the CPU count.
--explainPrints why each task re-runs: never built, command changed, outputs modified, or input rebuilt.
--timingPrints the time spent loading, planning and executing.
-v, --verbosePrints every command line.
--no-cacheIgnores the cached build plan and plans from scratch.

Swift packages

build resolves dependencies automatically when needed. These four options also work with resolve.

OptionDescription
--only-use-versions-from-resolved-fileResolves packages strictly to the versions in Package.resolved. Same as xcodebuild -onlyUsePackageVersionsFromResolvedFile.
--skip-package-updatesDoesn't fetch remote package repositories when resolving. Same as -skipPackageUpdates.
--disable-package-repository-cacheDoesn't use the shared package repository cache. Same as -disablePackageRepositoryCache.
--package-cache-path DIRShared package cache directory. Same as -packageCachePath.

Build products

  • The .app and intermediate files are in ~/DerivedData/<name>-<hash>/Build/Products/<config>-iphoneos/.
  • An iOS app is also packaged as <project dir>\build\<App>.ipa for Release, or <App>-<Config>.ipa for other configurations. When the app embeds Swift libraries, the .ipa includes the SwiftSupport/ folder that App Store Connect requires. Next to a Release .ipa, <App>.AppStoreInfo.plist is the optional asset description for uploading with Transporter.
  • --emit-commands-only writes only <project root>/compile_commands.json.
  • With --json, the last result includes success, the product paths, the .ipa paths and the duration.

Examples

> kxbuild build .\MyApp.xcodeproj --install
> kxbuild build .\MyApp.xcworkspace -s MyApp -c Release --clean -D CODE_SIGN_IDENTITY="Apple Distribution"
> kxbuild build .\MyApp.xcodeproj --sdk iphonesimulator --arch arm64 -D CODE_SIGNING_ALLOWED=NO
> kxbuild build .\MyApp.xcodeproj --emit-commands-only

In order: a Debug build installed on the iPhone, a Release .ipa signed with a Distribution certificate chosen on the command line, a simulator build that compiles without signing, and a completion database for the editor only.

Scripts and CI

All of these commands work in a CI pipeline. They exit with 0 on success and non-zero on failure. A typical CI command for a release .ipa looks like this.

> kxbuild build MyApp.xcworkspace -s MyApp -c Release --clean --derivedDataDir .\out --skip-package-updates --ipa .\out\MyApp.ipa --json
OptionWhy
--jsonPrints one JSON event per line. Scripts read the result from the success and product path fields. Leave it off when troubleshooting.
--derivedDataDir DIRKeeps build output inside the workspace, starting from a clean folder each time, so products are easy to collect.
--skip-package-updatesKeeps Swift packages at the versions in Package.resolved without fetching remotes, so builds are reproducible.
--cleanKeeps intermediate files from the previous build out.

When React Native, Expo or Flutter build scripts call xcodebuild and xcrun, they run the KXBuild commands of the same name, so the scripts work unchanged. See xcodebuild and xcrun compatibility.

resolve

kxbuild resolve <project.xcodeproj | project.xcworkspace | package dir> [options]

Resolves the project's Swift package dependencies and checks them out to <DerivedData>/<name>-<hash>/SourcePackages/. build does this automatically. Run it on its own to warm the cache or reset broken dependencies.

OptionDescription
--forceResets the package checkouts and caches before resolving. Same as Reset Package Caches in Xcode.
--derivedDataDir DIRSame as for build.
--only-use-versions-from-resolved-file and the other threeSame as the Swift package options of build.
> kxbuild resolve .\MyApp.xcodeproj --force

project

Inspects, creates, edits and converts Xcode projects, and adds Swift package dependencies and app extensions. For what each built-in template generates and how to add your own, see Project templates.

SubcommandDescription
infoPrints targets, schemes, bundle IDs and executable paths as JSON.
templatesLists the available project templates.
createCreates a project from a template.
settings dump / applyReads build settings, or changes them in bulk.
add-settingAdds or changes one build setting.
add-folderAdds a folder group to the project.
add-resourceAdds a resource file to a target, such as .xcstrings or .xcassets
add-packageAdds a Swift package dependency to a target.
add-targetAdds an app extension, App Clip, framework, static library or resource bundle to a project.
spm2appTurns a Swift package whose executable target is an app into an app project that builds an .ipa.

project info

kxbuild project info <project.xcodeproj | project.xcworkspace> [options]

Prints the project's targets, schemes, bundle IDs and executable paths as JSON.

OptionDescription
-c, --config NAMEReads settings from this configuration. Defaults to the one build would use.
--srcIncludes each target's source files and header search paths.
--derivedDataDir DIRMakes executablePath match the output directory of build.
> kxbuild project info .\MyApp.xcodeproj --src

project templates

kxbuild project templates

Lists the available project templates with their id, name, description and required tools. Pass the id to create -t. For what each template contains, see Project templates.

project create

kxbuild project create -t <template id> -n <name> [-b <bundle ID>] [-o <parent dir>] [--force] [--no-script]

Creates a project at <parent dir>/<name>. The CocoaPods, Flutter, React Native and Expo templates then run their setup steps, such as pod install or flutter create.

OptionDescription
-t, --type IDTemplate id, from templates or Project templates. Required.
-n, --name NAMEProject name. Starts with a letter and contains only letters, digits and underscores. Also used as the directory name. Required.
-b, --bundle-id IDBundle ID. Defaults to com.example.<name>.
-o, --output DIRParent directory. Defaults to the current directory.
--forceCreates the project in a non-empty directory.
--no-scriptCopies the template without running its generator script.
> kxbuild project create -t app_swiftui -n MyApp -b com.example.myapp -o D:\projects

On Windows, the React Native and Expo templates create deeply nested dependency folders. Use a short parent directory such as D:\p to stay under the 260-character path limit.

project settings dump / apply

kxbuild project settings dump <project> [--project NAME] [--all] [--ops FILE] [--derivedDataDir DIR]

Prints the raw and resolved settings of every target and configuration, plus setting metadata, as JSON. --all also lists settings that aren't set explicitly. --project picks a project when the workspace has several. --ops FILE applies the changes in memory before computing, as a preview, and writes nothing.

kxbuild project settings apply <project> --ops FILE [--project NAME]

Applies a batch of changes to project.pbxproj. FILE is a JSON array with one operation per item. op is set, remove or rename. owner is project or a target name. config is a configuration name, or * for all configurations. value is a string or an array of strings, and rename uses newKey. The Project Settings Editor calls this when it saves.

[ {"op": "set", "owner": "MyApp", "config": "*", "key": "MARKETING_VERSION", "value": "1.2.0"}, {"op": "set", "owner": "project", "config": "Debug", "key": "OTHER_LDFLAGS", "value": ["$(inherited)", "-ObjC"]}, {"op": "remove", "owner": "MyApp", "config": "Release", "key": "ENABLE_BITCODE"} ]
> kxbuild project settings apply .\MyApp.xcodeproj --ops ops.json

project add-setting

kxbuild project add-setting -k KEY -v VALUE -P <project.xcodeproj> [-t TARGET] [-c CONFIG] [-a]

Adds or changes one build setting. Quicker than an ops file for a single change.

OptionDescription
-k, --key KEYSetting name, such as HEADER_SEARCH_PATHS.
-v, --value VALUEValue. For an array, separate items with commas and add -a.
-a, --arrayWrites the comma-separated value as an array.
-t, --target NAMETarget to change. Without it, changes the project level.
-c, --config NAMEChanges only this configuration. Without it, changes all configurations.
-P, --project PATHPath to the .xcodeproj. Required.
> kxbuild project add-setting -k IPHONEOS_DEPLOYMENT_TARGET -v 15.0 -t MyApp -P .\MyApp.xcodeproj

project add-resource

kxbuild project add-resource -f <file> -P <project.xcodeproj> [-t TARGET]

Adds a resource file to a target's resources, such as a new Localizable.xcstrings, Assets.xcassets or .storyboard. Create the file first. A file already in the project is reused, and files inside an Xcode 16 folder (synchronized folder) don't need adding.

OptionDescription
-f, --file PATHThe resource file, absolute or relative to the project's folder
-t, --target NAMEThe target to add it to. Defaults to the first one
-P, --project PATHPath to the .xcodeproj. Required
> kxbuild project add-resource -f MyApp\Localizable.xcstrings -t MyApp -P .\MyApp.xcodeproj

project add-folder

kxbuild project add-folder -f <folder name> -P <project.xcodeproj> [-p <parent group>]

Adds a folder group to the project's group tree. Without -p, adds it at the root.

project add-package

kxbuild project add-package -P <project.xcodeproj> (--url URL [version rule] | --path DIR) [--product P,…] [-t TARGET]

Adds a Swift package dependency to a target, like Add Package Dependencies in Xcode. It resolves the package right away and updates Package.resolved. If a product name is wrong or resolution fails, the project is left unchanged. Without a version rule, a remote package uses the latest version, up to the next major version. If the repository has no version tags, it tracks the default branch. Needs network access.

OptionDescription
-P, --project PATHPath to the .xcodeproj. Required.
--url URLGit URL of a remote package.
--path DIRDirectory of a local package. Use either this or --url.
--product P,…Library products to link, comma separated. Optional when the package has only one library product. With several, omitting it lists the choices.
-t, --target NAMETarget that links the products. Defaults to the first target.
--from VERSIONUp to the next major version, starting from this version.
--up-to-next-minor VERSIONUp to the next minor version, starting from this version.
--exact VERSIONExactly this version.
--range A..<BVersion range, such as 5.0.0..<6.0.0.
--branch NAMETracks this branch.
--revision SHAPins to this commit.
--no-resolveOnly edits the project, without resolving over the network. The next build resolves it. Requires --product, and a version rule for a remote package.
> kxbuild project add-package -P .\MyApp.xcodeproj --url https://github.com/Alamofire/Alamofire.git --from 5.9.0 --product Alamofire
> kxbuild project add-package -P .\MyApp.xcodeproj -t MyApp --path ..\MyKit

project add-target

kxbuild project add-target -P <project.xcodeproj> --type <type> --name <name> [--language swift|objc] [--host TARGET | --no-host] [--bundle-id ID] [--app-group ID]

Adds a target to a project, such as an app extension like a widget, an App Clip, a framework, a static library or a resource bundle. It's the equivalent of Xcode's File > New > Target. The sources go into a folder of the same name next to the .xcodeproj, and the new target is built and installed with the app, with the same build configurations. If anything fails, the project is left unchanged. Before signing an extension or App Clip, register an App ID and create a provisioning profile for its bundle ID in the Apple Developer portal. With --app-group, also enable App Groups on both App IDs. The command output lists what's needed. See Certificates and signing.

OptionDescription
-P, --project PATHPath to the .xcodeproj. Required
--type TYPEThe target type, see the table below. Required
--name NAMEThe target name, also used for the source folder. Letters, digits and underscores, starting with a letter. Required
--language LANGLanguage of a framework or static library, swift or objc. Defaults to swift
--host NAMEThe app target to add it to. Optional when the project has only one app
--no-hostAdds a framework, static library or resource bundle without adding it to any app
--bundle-id IDThe bundle ID. For an extension it defaults to the app's bundle ID plus a dot and the lowercased name, and must start with the app's bundle ID and a dot
--app-group IDAn App Group shared by the app and the extension or App Clip, such as group.com.example.myapp. Use it when they share data
--listLists every type
TypeWhat it does
frameworkDynamic framework, linked and embedded in the app. Swift or Objective-C
static-libraryStatic library, linked into the app. Swift or Objective-C
bundleResource bundle, copied into the app
app-clipApp Clip embedded in the app, bundle ID is the app's plus .Clip
widgetHome Screen and Lock Screen widget
widget-live-activityA widget plus a Live Activity for the Lock Screen and Dynamic Island
notification-serviceModifies push content before it's shown, downloads attachments
notification-contentCustom interface for expanded notifications
shareReceives text, links and images from the share sheet
actionActs on content from other apps through the share sheet
imessageiMessage extension in the Messages app
keyboardCustom keyboard
photo-editingEdits photos inside the Photos app
quicklook-previewPreviews custom files in Files and other apps
thumbnailGenerates thumbnails for custom files
safari-web-extensionSafari web extension
content-blockerSafari content blocker
broadcast-uploadBroadcast upload extension for screen broadcasting
broadcast-setup-uiSetup screen shown before a screen broadcast starts
file-providerProvides your cloud files in the Files app. Needs an App Group
credential-providerSupplies passwords for AutoFill
call-directoryCaller ID and call blocking
message-filterFilters text messages from unknown senders
network-extensionVPN tunnel (Packet Tunnel)
device-activity-monitorScreen Time device activity monitor
shield-configurationScreen Time shield appearance
shield-actionHandles the buttons on a Screen Time shield
background-downloadAsset packs the system downloads at install and update. iOS 26 and later
> kxbuild project add-target -P .\MyApp.xcodeproj --type widget --name MyAppWidget --app-group group.com.example.myapp

project spm2app

kxbuild project spm2app <package dir> [-n NAME] [-b ID] [--executable E] [-o DIR] [--force] [--no-resolve]

For a package whose executable target is a SwiftUI or UIKit app, creates an iOS app project from that code and references the package as a local package. Build that project with build to get an .ipa. By default the project goes in <package dir>\<App name>\, so you commit it together with the package. Library-only packages are not converted. Add them to an app project with add-package instead. If a target in the same package that the app uses has no library product, spm2app adds a .library line to Package.swift and lists that change in its output. For the full workflow, see Swift packages.

OptionDescription
-n, --name NAMEApp name. Defaults to the name of the app executable.
-b, --bundle-id IDBundle ID. Defaults to com.example.<App name>.
--executable EPicks the app executable to convert when the package has several.
-o, --output DIRParent directory. The project is created at <DIR>\<App name>. Defaults to the package directory.
--forceCreates the project in a non-empty directory.
--no-resolveDoesn't resolve packages after generating the project.
> kxbuild project spm2app . -n MyApp -b com.example.myapp

update

kxbuild update [--check] [--no-doctor]

Updates kxbuild to the latest version by downloading it and replacing the local binary, ready to run. Afterwards, runs doctor once with the new version.

OptionDescription
--checkOnly reports whether a newer version exists. Installs nothing.
--no-doctorDoesn't run doctor after updating.
> kxbuild update --check

version

kxbuild version [--json]

Prints version information. With --json, prints a single JSON object that scripts can use to check the version. Include this output when you ask for help.

Next steps