Skip to content

Instantly share code, notes, and snippets.

@leviathan
Last active August 29, 2025 19:44
Show Gist options
  • Select an option

  • Save leviathan/0c806022cd83d0a51a15c92b6b53db49 to your computer and use it in GitHub Desktop.

Select an option

Save leviathan/0c806022cd83d0a51a15c92b6b53db49 to your computer and use it in GitHub Desktop.
xcrun cheat sheet

Environment Info

xcode-select --print-path
xcodebuild -version
swift --version
swift build --version
pkgutil --pkg-info=com.apple.pkg.CLTools_Executables | grep version   // Check Xcode Command-Line-Tools Version

xcrun

Get help

$ xcrun simctl help
usage: simctl [--set <path>] [--profiles <path>] <subcommand> ...
       simctl help [subcommand]
Command line utility to control the Simulator

Run the list subcommand to get a list of the available runtimes, device types, devices, and device pairs:

$ xcrun simctl list
-- iOS 12.1 --
    iPhone 5s (CC96B643-067E-41D5-B497-1AFD7B3D0A13) (Shutdown)
    iPhone 6 (7A27C0B9-411A-4BCD-8A67-68F00DF39C1A) (Shutdown)
    iPhone 6 Plus (A5918644-8D46-4C67-B21E-68EA25997F91) (Shutdown)
    iPhone 6s (1AB5A4EB-2434-42E4-9D2C-42E479CE8BDC) (Shutdown)
…

One such subcommand is boot, which starts up the specified device, making it available for interaction:

$ xcrun simctl boot $UUID
$ xcrun simctl shutdown $UUID
$ xcrun simctl erase $UUID

// Removes old simulators, which xcode no longer uses

$ xcrun simctl delete unavailable

Opening URLs in Simulator

// xcrun allows you to invoke developer tools from the terminal. // In this case simctl, which is a command line utility to control the iOS Simulator. // simctl has the subcommand: openurl to open URLs in a given simulator // most of the cases you would like to open on the current booted device, so you add // the flag booted or type the simulator id.

$ xcrun simctl openurl booted "http://google.com"

// open app url
$ xcrun simctl openurl booted "ios-cobi://bike.cobi/app?state=w4BZrykXl7..."

// Print the UUID of the device in your simulator

$ xcrun simctl list | egrep '(Booted)'
iPhone X (9FED67A2-3D0A-4C9C-88AC-28A9CCA44C60) (Booted)

Get the list in structured format:

$ xcrun simctl list --json

Reference: https://nshipster.com/simctl/

@IshanG97
Copy link

this is very useful. Do you know how to open the url on a real device? I was trying xcrun devicectl device process launch --device <device-udid> com.apple.mobilesafari --payload-url http://www.google.com but no luck

@leviathan
Copy link
Author

@IshanG97 no, I don't know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment