← 返回命令列表

Linux command

xcrun 命令

文件

复制后可按需替换文件名、目录或参数。

常用示例

Find the path

xcrun --find [clang]

Run a tool

xcrun [clang] [arguments]

List available SDKs

xcrun --show-sdk-path --sdk [iphoneos]

Run with a specific SDK

xcrun --sdk [macosx] [tool] [arguments]

Show the current developer directory path

xcrun --show-sdk-platform-path

Switch toolchain

xcrun --toolchain [XcodeDefault] [swift] --version

Run simulator

xcrun simctl boot "[iPhone 15]"

Notarize an app

xcrun notarytool submit [app.zip] --apple-id [email] --team-id [TEAM_ID] --password [password]

说明

xcrun is macOS's command-line utility for locating and invoking developer tools from the Xcode toolchain. It serves as an intelligent wrapper that finds the correct version of tools like clang, swift, ld, and others based on the active Xcode installation and selected SDK. The tool resolves the complexity of having multiple Xcode versions or SDKs installed by automatically selecting the appropriate tool version. It respects the DEVELOPER_DIR environment variable and the setting from xcode-select, making it essential for build scripts and CI/CD pipelines that need consistent tool resolution. Beyond simple tool invocation, xcrun provides access to powerful subcommands through tools like simctl for iOS Simulator management, notarytool for app notarization, altool for App Store uploads, and stapler for attaching notarization tickets.

参数

--sdk _sdkname_
Use the specified SDK (e.g., macosx, iphoneos, iphonesimulator).
--toolchain _name_
Use the specified toolchain.
--find _tool_
Print the full path to the specified tool.
--run _tool_
Run the specified tool (default behavior when tool name given).
--show-sdk-path
Print the path to the selected SDK.
--show-sdk-version
Print the version of the selected SDK.
--show-sdk-platform-path
Print the platform path for the selected SDK.
--show-sdk-platform-version
Print the platform version for the selected SDK.
--log
Print the executed command to stderr.
--verbose
Show verbose output.
--no-cache
Do not use cached values for tool paths.
--kill-cache
Clear the tool path cache.
-h, --help
Display help information.

FAQ

What is the xcrun command used for?

xcrun is macOS's command-line utility for locating and invoking developer tools from the Xcode toolchain. It serves as an intelligent wrapper that finds the correct version of tools like clang, swift, ld, and others based on the active Xcode installation and selected SDK. The tool resolves the complexity of having multiple Xcode versions or SDKs installed by automatically selecting the appropriate tool version. It respects the DEVELOPER_DIR environment variable and the setting from xcode-select, making it essential for build scripts and CI/CD pipelines that need consistent tool resolution. Beyond simple tool invocation, xcrun provides access to powerful subcommands through tools like simctl for iOS Simulator management, notarytool for app notarization, altool for App Store uploads, and stapler for attaching notarization tickets.

How do I run a basic xcrun example?

Run `xcrun --find [clang]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does --sdk _sdkname_ do in xcrun?

Use the specified SDK (e.g., macosx, iphoneos, iphonesimulator).