>_ZSH-XCODE-COMPLETIONS
Xcode command-line tools, completed. Zsh completions for the Xcode command-line tools, with xcrun-shim binaries to work around xcrun's nested-command completion limitation.
Install
# Homebrew (recommended)
brew install keith/formulae/zsh-xcode-completions
# Zinit
zinit ice lucid nocompile
zinit load MenkeTechnologies/zsh-xcode-completions
# Oh My Zsh
git clone https://github.com/MenkeTechnologies/zsh-xcode-completions \
"$HOME/.oh-my-zsh/custom/plugins/zsh-xcode-completions"
# then: plugins+=(zsh-xcode-completions)
# Manual
git clone https://github.com/MenkeTechnologies/zsh-xcode-completions
# source the plugin file or copy _* files onto your fpath
The Homebrew formula installs the shim binaries to PATH. If you don't want shims, install with --without-shims.
Covered binaries
Eleven #compdef completers live under src/, one per tool. Each is autoloaded by zsh's completion system after the plugin prepends src/ to fpath.
xcodebuild | build / analyze / archive / test / install — 31 flags + 7 build actions, project-aware |
xcrun | locate / run developer tools (with shim for nested completion) |
xcode-select | switch / print / reset active developer directory |
genstrings | extract .strings from source |
nm | symbol-table dump — 18 flags incl. -arch enum |
strings | printable-string extraction — flags + -arch enum |
dyldinfo | dyld load-command / binding / rebase inspector |
plutil | property-list lint / convert / extract / edit |
instruments | profiling — template + attach-pid completion |
swift | Swift compiler driver — emit / search-path / SDK flags |
swift-demangle | demangle Swift symbols |
Examples
Every example below maps to a real completion state in one of the src/_* files. Press TAB at the cursor:
xcodebuild -scheme <TAB> # schemes parsed from `xcodebuild -list` xcodebuild -target <TAB> # targets parsed from `xcodebuild -list` xcodebuild -configuration <TAB> # configs parsed from `xcodebuild -list` xcodebuild -arch <TAB> # VALID_ARCHS from `xcodebuild -showBuildSettings` xcodebuild -sdk <TAB> # cached SDK list (`xcodebuild -showsdks`) xcodebuild -project <TAB> # glob *.xcodeproj xcodebuild -workspace <TAB> # glob *.xcworkspace xcodebuild <TAB> # build actions: build/clean/test/archive/… xcrun <TAB> # tools in $(dirname $(xcrun -f swift)) xcrun --sdk <TAB> # cached SDK platforms xcrun --toolchain <TAB> # glob installed .xctoolchain dirs xcode-select --switch <TAB> # glob /Applications/Xcode*.app plutil -convert <TAB> # json / xml1 / binary1 nm -arch <TAB> # arm64 / armv7 / armv7s / i386 / x86_64 instruments -t <TAB> # templates from `instruments -s templates`
Per-tool flag reference
Every flag below is taken directly from the src/_* completers. Flags marked with “→” offer value completion at the next TAB.
xcodebuild | 31 flags. Project-aware values: -scheme→, -target→, -configuration→, -arch→, -sdk→, -project→*.xcodeproj, -workspace→*.xcworkspace, -xcconfig→*.xcconfig. Path values: -archivePath, -derivedDataPath, -resultBundlePath. Toggles (YES/NO): -enableAddressSanitizer, -enableThreadSanitizer, -enableUndefinedBehaviorSanitizer, -enableCodeCoverage. Switches: -n/-dry-run, -alltargets, -list, -showsdks, -showBuildSettings, -skipUnavailableActions, -usage, -version. Archive/export: -exportArchive, -exportFormat (IPA/PKG/APP), -exportInstallerIdentity, -exportProvisiningProfile, -exportSigningIdentity, -exportWithOriginalSigningIdentity, -destination, -destination-timeout. Actions: analyze, archive, build, clean, install, installsrc, test. |
xcrun | -f/--find, -h/--help, -k/--kill-cache, -l/--log, -n/--no-cache, -r/--run, -v/--verbose, --sdk→, --toolchain→, --show-sdk-path, --show-sdk-platform-path, --show-sdk-platform-version, --show-sdk-version, --version. Positional tool name completes from $(dirname $(xcrun -f swift)). |
xcode-select | -h/--help, -p/--print-path, -r/--reset, -s/--switch→ (glob /Applications/Xcode*.app), -v/--version, --install. |
swift | -assert-config (Debug/Release/Replacement), -D, -emit-assembly, -emit-library, -emit-object, -F→, -framework→, -g, -gline-tables-only, -gnone, -help, -I→, -j, -L→, -l→, -module-cache-path→, -module-link-name, -module-name, -nostdimport, -O, -o→, -Onone, -Ounchecked, -sdk→ (cached), -target-cpu, -target, -v, -version, -Xcc, -Xlinker. |
swift-demangle | -classify, -compact, -expand, -help, -help-list-hidden, -no-sugar, -remangle-new, -simplified, -test-remangle, -tree-only, -version. Positional args are the symbol(s) to demangle. |
nm | -a, -A, -arch→ (arm64/armv7/armv7s/i386/x86_64), -f, -g, -j, -l, -m, -n, -o, -p, -P, -r, -s, -t (d/o/x), -u, -U, -x. Positional → files. |
strings | - (all bytes), -a (all sections), -arch→ (same enum as nm), -n (min length), -o (offset), -t (d/o/x). Positional → files. |
dyldinfo | -arch→ (i386/x86_64/armv7/arm64), -dylibs, -rebase, -bind, -weak_bind, -lazy_bind, -export, -opcodes, -function_starts. Positional → Mach-O files. |
plutil | -convert→ (json/xml1/binary1), -insert, -replace (both: keypath → type -bool/-integer/-float/-string/-date/-data/-xml/-json → value), -remove, -extract→, -e, -help, -lint, -o→, -p, -r, -s. Positional → files. |
instruments | -w (target device/sim), -v, -t→ (templates, cached), -s (templates/devices), -D→ (trace doc), -l (time limit), -i (instrument index). Mutex modes: -p→_pids (attach) vs. positional command name (launch). |
genstrings | -a, -macRoman, -noPositionalParameters, -o→ (output dir), -q, -s (custom NSLocalizedString fn), -skipTable, -u. Positional → source files. |
How completion data is sourced
Most static flags are inline enums, but the context-sensitive values are queried live at TAB time:
| schemes / targets / configurations | xcodebuild -list, section-sliced with sed |
| valid archs | xcodebuild -showBuildSettings | grep VALID_ARCHS | cut -f2 -d= |
| SDK list | xcodebuild -showsdks, cached under key SDKS (shared by xcodebuild + swift) and SDK_PLATFORMS (xcrun) |
| xcrun tool names | ls $(dirname $(xcrun -f swift)) |
| toolchains | glob /Applications/Xcode*.app/Contents/Developer/Toolchains/*.xctoolchain |
| instruments templates | instruments -s templates → ${(Q)${(f)...}} split/unquote, header dropped, cached as _instruments_templates |
Configuration
- fpath — the plugin's sole job is
fpath=("${0:h}/src" $fpath). Whatever loader you use must runcompinitafter sourcing the plugin so the_*files are picked up. - Completion cache — SDK lists use zsh's
_store_cache/_retrieve_cache. To benefit, enable the cache policy in your.zshrc:zstyle ':completion:*' use-cache on. Cache keys:SDKS,SDK_PLATFORMS,_instruments_templates. Reinstalling an SDK invalidatesSDKSfor bothxcodebuildandswift. - Shims — the Homebrew formula installs
bin/swift-demangle(a#!/bin/shwrapper runningxcrun swift-demangle "$@") ontoPATHso the_swift-demanglecompleter can fire. Install with--without-shimsto skip it. Tradeoff: you cannot pass arguments toxcrunitself when calling through a shim.
Troubleshooting
- No completions appear — confirm
compinitruns after the plugin loads, and thatsrc/is onfpath(echo $fpath | tr ' ' '\n' | grep zsh-xcode). - Stale SDK / scheme list — the SDK list is cached; clear it with
rm "$ZSH_COMPDUMP"*and the zsh completion cache dir, or just open a new shell. Scheme/target/config lists are not cached and re-queryxcodebuild -listevery TAB. - Project queries are slow — each
-scheme/-target/-archTAB spawnsxcodebuild, which is inherently slow in large projects. This is the cost of project-correct values over static enums. - swift-demangle won't complete through xcrun — that is the limitation the shim exists for. Either install the shim (default Homebrew behavior) or invoke
swift-demangleas a direct PATH binary.
Sibling plugins
Part of the MenkeTechnologies zsh plugin family — the MenkeTechnologiesMeta umbrella:
- zsh-better-npm-completion — cache-aware
npm installcompletion - zsh-cargo-completion — live
cargo add/cargo installcompletion - zsh-cpan-completion — live MetaCPAN
cpan/cpanmcompletion - zsh-dotnet-completion — dotnet CLI completion
- zsh-expand — spacebar expansion (11,683 tests)
- zsh-gem-completion — ruby
gem installremote completion - zsh-git-acp — 159 git aliases + add/commit/push keybindings
- zsh-git-repo-cache — index every git repo on disk
- zsh-learn — MySQL-backed learning collection / quiz
- zsh-more-completions — 33,175-file mega completion corpus
- zsh-nginx — nginx commands + service-wrapper aliases
- zsh-pip-description-completion — pip remote completion with descriptions
- zsh-sed-sub — in-place sed substitution on the command line
- zsh-sudo — ESC ESC to prepend sudo