xcrun

Run or locate development tools and properties.

xcrun [--sdk SDK name] --find tool name

xcrun [--sdk SDK name] tool name ... tool arguments ...

tool name … tool arguments ...

locate or invoke developer tools from the command-line, without requiring modifying Makefiles or otherwise take inconvenient measures to support multiple Xcode tool chains.

Install using xcode-select --install or from https://developer.apple.com/download/more

xcode-select is used to set a system default for the active developer directory, and may be overridden by

$DEVELOPER_DIR

The SDK which will be searched defaults to the most recent available SDK, and can be specified by $SDKROOT or --sdk (which takes precedences over $SDKROOT). When used to invoke another tool (as opposed to simply finding it), xcrun provides the absolute path to the selected SDK in $SDKROOT.

Usage

With --find , as in xcrun [--sdk SDKname] --find tool name,
the absolute path to the tool (in the provided SDK, if given) is output.
Without --find the name of a tool is required and the tool will be executed with the provided arguments.

When used as the target of a symbolic link, it derives the tool name to use from the name it was invoked under, and then executes that tool.

-v
--verbose
information on how the lookup is performed.
--sdk sdkname The SDK to search for tools. widthout sdkname SDK used will be taken from $SDKROOT
Use xcodebuild -showsdks to list the available SDK names.
--toolchain which toolchain to use to perform the lookup.
If no --toolchain is provided, then the toolchain is taken from $TOOLCHAINS.
-r
--run
run mode, the resolved tool path is executed with additional arguments.
the default mode.
-f
--find
find mode, the resolved tool path is output.
--show-sdk-path output the path to the SDK.
--show-sdk-version output the version number of the SDK.
--show-sdk-build-version output the build version number of the SDK.
--show-sdk-platform-path output the path to the platform for the SDK.
--show-sdk-platform-version output the version number of the platform for the SDK.
-n
--no-cache
cache is NOT checked, causes the cache entry to be refreshed.
-k
--kill-cache
Removes the cache.

ENVIRONMENT

$CPATH modified by xcrun to include /usr/local/include when an explicit SDK is not requested via environment variable nor command line argument and neither -nostdinc nor -nostdsysteminc are present.
$DEVELOPER_DIR Overrides the active developer directory. used instead of the system-wide active directory.
$LIBRARY_PATH modified by xcrun to include /usr/local/lib when an explicit SDK is not requested via environment variable nor command line argument and -Z is not being passed to the linker.
$SDKROOT default SDK to be used when looking up tools (some tools may have SDK specific versions).

Set by xcrun to be the absolute path to the user provided SDK (either via $SDKROOT or --sdk ), when it is used to invoke a normal tool (build tools like xcodebuild or make are exempt from this behavior).

For example, if xcrun is used to invoke clang via:
xcrun --sdk macosx clang test.c xcrun provides the full path to the macosx SDK in the environment variable $SDKROOT which will be used by ,code>clang to select that SDK when compiling.

$TOOLCHAINS default toolchain to be used when looking up tools (for tools which are toolchain specific).

aliases

xcrun_log :: --log.

xcrun_nocache :: >--no-cache.

xcrun_verbose :: --verbose.

EXAMPLES

Find the path to the clang binary in the default SDK. xcrun --find clang

Find the path to the texturetool binary in the iOS SDK. xcrun --sdk iphoneos --find texturetool

Output the path to the current Mac OS X SDK. xcrun --sdk macosx --show-sdk-path

Locate the git command and then executes it with status xcrun git status

xcrun simctl delete unavailable

Command line utility to control the Simulator

usage: simctl [--set path] [--profiles path] subcommand …
       simctl help [subcommand]
For subcommands that require a device , specify a device UDID
or the special "booted" string which will cause simctl to pick a booted device.
Subcommands: create a new device. clone an existing device. upgrade a device to a newer runtime. delete a device or all unavailable devices. erase a device's contents and settings. pair Create a new watch and phone pair. unpair Unpair a watch and phone pair. pair_activate Set a given pair as active. boot Boot a device. shutdown Shutdown a device. rename Rename a device. getenv Output an environment variable from a running device. openurl Open a URL in a device. addmedia Add photos, live photos, videos, or contacts to the library of a device. install Install an app on a device. uninstall Uninstall an app from a device. launch Launch an application by identifier on a device. get_app_container output the path of the installed app's container terminate Terminate an application by identifier on a device. spawn Spawn a process by executing a given executable on a device. list List available devices, device types, runtimes, or device pairs. icloud_sync Trigger iCloud sync on a device. pbsync Sync the pasteboard content from one pasteboard to another. pbcopy Copy standard input onto the device pasteboard. pbpaste output the contents of the device's pasteboard to standard output. help output the usage for a given subcommand. io Set up a device IO operation. diagnose Collect diagnostic information and logs. logverbose enable or disable verbose logging for a device xcrun --verbose --log simctl delete unavailable xcrun: note: PATH = 'Library/Developer/CommandLineTools/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:opt/X11/bin:/usr/libexec:/usr/local/bin' xcrun: note: SDKROOT = '/' xcrun: note: TOOLCHAINS = '' xcrun: note: DEVELOPER_DIR = '/Applications/Xcode.app/Contents/Developer' xcrun: note: XCODE_DEVELOPER_USR_PATH = '' xcrun: note: xcrun_db = '/var/folders/rr/jvwb6c9j2h18lzc28kzws_940000gn/T/xcrun_db' xcrun: note: xcrun via simctl (xcrun) xcrun: note: database key is: simctl|/||/Applications/Xcode.app/Contents/Developer| xcrun: note: lookup resolved in '/var/folders/rr/jvwb6c9j2h18lzc28kzws_940000gn/T/xcrun_db' : '/Applications/Xcode.app/Contents/Developer/usr/bin/simctl' /Applications/Xcode.app/Contents/Developer/usr/bin/simctl delete unavailable

DIAGNOSTICS

xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), 
                           missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
When invoked as xcrun; --log and --verbose are useful debugging aids.
--no-cache bypasses cache lookup, at a significant cost in performance.

When xcrun has taken the place of another tool, the arguments are those of the tool replaced, and
the various xcrun options can't be used. In this case, use the specific environment variables instead.

SEE

xcodebuild, xcode-select