diff --git a/README.md b/README.md index 316bdc9..36a5b00 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ Zsh completions for some of the Xcode command line tools. Currently: - [`plutil`](https://developer.apple.com/legacy/library/documentation/Darwin/Reference/ManPages/man1/plutil.1.html) - [`xcode`-select](https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man1/xcode-select.1.html) - [`xcodebuild`](https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man1/xcodebuild.1.html) -- [`xcrun`](https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man1/xcrun.1.html) See [shims](#shims) for more info +- [`xcrun`](https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man1/xcrun.1.html) - `strings` - `swift-demangle` - `swift` @@ -25,17 +25,6 @@ brew install keith/formulae/zsh-xcode-completions - pkgutil - pmset -### Shims - -Unfortunately, because of how `xcrun` happens to work, creating -completions that also handle the nested completions for programs run -through `xcrun` (such as `swift-demangle`) has proven to be difficult. -To get around this, I have created [shims](bin) for programs that could -use completions. I've also added a homebrew option (`--without-shims`) -if you would like to exclude these from being installed. One -disadvantage to this approach is you cannot pass arguments to the -`xcrun` command while calling a shim. - ### Resources diff --git a/bin/swift-demangle b/bin/swift-demangle deleted file mode 100755 index e78641b..0000000 --- a/bin/swift-demangle +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -xcrun swift-demangle "$@" diff --git a/specs/Makefile b/specs/Makefile new file mode 100644 index 0000000..a7c1a6e --- /dev/null +++ b/specs/Makefile @@ -0,0 +1,49 @@ +all: simctl.txt + +%.txt: FORCE + $(MAKE) "$(basename $@)" &>$@ + +FORCE: + +simctl: + xcrun simctl || true + @for command in $$(xcrun simctl | grep '^\t' | awk '{print $$1}'); do \ + echo; \ + echo xcrun simctl help $$command; \ + xcrun simctl help $$command; \ + done + @# Undocumented/internal commands: + @echo + xcrun simctl help addphoto + @echo + xcrun simctl help addvideo + @echo + xcrun simctl help pbinfo + @echo + xcrun simctl help notify_post + @echo + xcrun simctl help notify_get_state + @echo + xcrun simctl help notify_set_state + @echo + xcrun simctl help register + @echo + xcrun simctl help unregister + @echo + xcrun simctl help keyboard + @echo + xcrun simctl help monitor + @echo + xcrun simctl help appinfo + @echo + xcrun simctl help listapps + @echo + xcrun simctl help bootstatus + @echo + xcrun simctl help darwinup + @echo + xcrun simctl help disk + @echo + xcrun simctl help runtime + @echo + xcrun simctl help reset diff --git a/specs/simctl.txt b/specs/simctl.txt new file mode 100644 index 0000000..ca63021 --- /dev/null +++ b/specs/simctl.txt @@ -0,0 +1,674 @@ +xcrun simctl || true +usage: simctl [--set ] [--profiles ] ... + simctl help [subcommand] +Command line utility to control the Simulator + +For subcommands that require a argument, you may specify a device UDID +or the special "booted" string which will cause simctl to pick a booted device. +If multiple devices are booted when the "booted" device is selected, simctl +will choose one of them. + +Subcommands: + create Create a new device. + clone Clone an existing device. + upgrade Upgrade a device to a newer runtime. + delete Delete specified devices, unavailable devices, or all devices. + pair Create a new watch and phone pair. + unpair Unpair a watch and phone pair. + pair_activate Set a given pair as active. + erase Erase a device's contents and settings. + boot Boot a device or device pair. + shutdown Shutdown a device. + rename Rename a device. + getenv Print 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. + get_app_container Print the path of the installed app's container + install_app_data Install an xcappdata package to a device, replacing the current contents of the container. + launch Launch an application by identifier on a device. + 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 Print the contents of the device's pasteboard to standard output. + help Prints 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 + status_bar Set or clear status bar overrides + ui Get or Set UI options + push Send a simulated push notification + privacy Grant, revoke, or reset privacy and permissions + keychain Manipulate a device's keychain + +xcrun simctl help create +Create a new device. +Usage: simctl create [] + + A valid available device type. Find these by running "xcrun simctl list devicetypes". + Examples: ("iPhone X", "com.apple.CoreSimulator.SimDeviceType.iPhone-X") + A valid and available runtime. Find these by running "xcrun simctl list runtimes". + If no runtime is specified the newest runtime compatible with the device type is chosen. + Examples: ("watchOS3", "watchOS3.2", "watchOS 3.2", "com.apple.CoreSimulator.SimRuntime.watchOS-3-2", + "/Volumes/path/to/Runtimes/watchOS 3.2.simruntime") + + +xcrun simctl help clone +Clone an existing device. +Usage: simctl clone [] + +xcrun simctl help upgrade +Upgrade a device to a newer runtime. +Usage: simctl upgrade + +xcrun simctl help delete +Delete specified devices, unavailable devices, or all devices. +Usage: simctl delete [... ] | unavailable | all + +Specifying unavailable will delete devices that are not supported by the current Xcode SDK. + + +xcrun simctl help pair +Create a new watch and phone pair. +Usage: simctl pair + +xcrun simctl help unpair +Unpair a watch and phone pair. +Usage: simctl unpair + +xcrun simctl help pair_activate +Set a given pair as active. +Usage: simctl pair_activate + +xcrun simctl help erase +Erase a device's contents and settings. +Usage: simctl erase [... ] | all + +Specifying all will erase all existing devices. + +xcrun simctl help boot +Boot a device or device pair. +Usage: simctl boot [--disabledJob=] [--enabledJob=] + + --disabledJob= Disables the given launchd job. Multiple jobs can be disabled by passing multiple flags. + --enabledJob= Enables the given launchd job when it would normally be disabled. + Multiple jobs can be enabled by passing multiple flags. + + +If you want to set environment variables in the resulting environment, set them in the calling environment with a SIMCTL_CHILD_ prefix. + +xcrun simctl help shutdown +Shutdown a device. +Usage: simctl shutdown | all + +Specifying all will shut down all running devices + +xcrun simctl help rename +Rename a device. +Usage: simctl rename + +xcrun simctl help getenv +Print an environment variable from a running device. +Usage: simctl getenv + +xcrun simctl help openurl +Open a URL in a device. +Usage: simctl openurl + +xcrun simctl help addmedia +Add photos, live photos, videos, or contacts to the library of a device. +Usage: simctl addmedia [... ] + +You can specify multiple files including a mix of photos, videos, and contacts. + +You can also specify multiple live photos by providing the photo and video files. They will automatically be discovered and imported correctly. + +Contacts support the vCard format. + +xcrun simctl help install +Install an app on a device. +Usage: simctl install + +xcrun simctl help uninstall +Uninstall an app from a device. +Usage: simctl uninstall + +xcrun simctl help get_app_container +Print the path of the installed app's container +Usage: simctl get_app_container [] + +container Optionally specify the container. Defaults to app. + app The .app bundle + data The application's data container + groups The App Group containers + A specific App Group container + + + +xcrun simctl help install_app_data +Install an xcappdata package to a device, replacing the current contents of the container. +Usage: simctl install_app_data + This will replace the current contents of the container. If the app is currently running it will be terminated before the container is replaced. + +xcrun simctl help launch +Launch an application by identifier on a device. +Usage: simctl launch [-w | --wait-for-debugger] [--console|--console-pty] [--stdout=] [--stderr=] [--terminate-running-process] [ ... ] + + --console Block and print the application's stdout and stderr to the current terminal. + Signals received by simctl are passed through to the application. + (Cannot be combined with --stdout or --stderr) + --console-pty Block and print the application's stdout and stderr to the current terminal via a PTY. + Signals received by simctl are passed through to the application. + (Cannot be combined with --stdout or --stderr) + --stdout= Redirect the application's standard output to a file. + --stderr= Redirect the application's standard error to a file. + --terminate-running-process Terminate any running copy of the application. + Note: Log output is often directed to stderr, not stdout. + +If you want to set environment variables in the resulting environment, set them in the calling environment with a SIMCTL_CHILD_ prefix. + +xcrun simctl help terminate +Terminate an application by identifier on a device. +Usage: simctl terminate + +xcrun simctl help spawn +Spawn a process by executing a given executable on a device. +Usage: simctl spawn [-w | --wait-for-debugger] [-s | --standalone] [-a | --arch=] [ ... ] + +The path to the executable is searched using the following rules: + contains no / characters: search the device's $PATH. This is similar to how most shells work, but searches the device's path instead of the host's path. + starts with /: Assume a literal path to the binary. This must start from the host's root. + contains non-leading / characters: search relative to the current directory first, then relative to the device's $SIMULATOR_ROOT. + +If you want to set environment variables in the resulting environment, set them in the calling environment with a SIMCTL_CHILD_ prefix. + +xcrun simctl help list +List available devices, device types, runtimes, or device pairs. +Usage: simctl list [-j | --json] [-v] [devices|devicetypes|runtimes|pairs] [|available] +-j Print as JSON +-v More verbose output + +Specify one of 'devices', 'devicetypes', 'runtimes', or 'pairs' to list only items of that type. If a type filter is specified you may also specify a search term. Search terms use a simple case-insensitive contains check against the item's description. You may use the search term 'available' to only list available items. + + +xcrun simctl help icloud_sync +Trigger iCloud sync on a device. +Usage: simctl icloud_sync + +xcrun simctl help pbsync +Sync the pasteboard content from one pasteboard to another. +Usage: simctl pbsync [-pv] + + -p causes simctl to use promise data for secondary types. simctl will continue to run to provide that promise data until something else replaces it on the pasteboard. + +xcrun simctl help pbcopy +Copy standard input onto the device pasteboard. +Usage: simctl pbcopy [-v] + +xcrun simctl help pbpaste +Print the contents of the device's pasteboard to standard output. +Usage: simctl pbpaste [-v] + +xcrun simctl help help +Prints the usage for a given subcommand. +Usage: simctl help + +xcrun simctl help io +Set up a device IO operation. +Usage: simctl io + +Supported operations: + enumerate [--poll] + Lists all available IO ports and descriptor states. + --poll Poll after enumeration. + + poll + Polls all available IO ports for events. + + recordVideo [--codec=] [--display=] [--mask=] [--force] + Records the display to a QuickTime movie at the specified file or url. + --codec Specifies the codec type: "h264" or "hevc". Default is "hevc". + + --display iOS: supports "internal" or "external". Default is "internal". + tvOS: supports only "external" + watchOS: supports only "internal" + + --mask For non-rectangular displays, handle the mask by policy: + ignored: The mask is ignored and the unmasked framebuffer is saved. + alpha: Not supported, but retained for compatibility; the mask is rendered black. + black: The mask is rendered black. + + --force Force the output file to be written to, even if the file already exists. + + screenshot [--type=] [--display=] [--mask=] + Saves a screenshot as a PNG to the specified file or url(use "-" for stdout). + --type Can be "png", "tiff", "bmp", "gif", "jpeg". Default is png. + + --display iOS: supports "internal" or "external". Default is "internal". + tvOS: supports only "external" + watchOS: supports only "internal" + + You may also specify a port by UUID + --mask For non-rectangular displays, handle the mask by policy: + ignored: The mask is ignored and the unmasked framebuffer is saved. + alpha: The mask is used as premultiplied alpha. + black: The mask is rendered black. + +Example: + Save a screenshot of the booted device to screenshot.png: + simctl io booted screenshot screenshot.png + + + +xcrun simctl help diagnose +Collect diagnostic information and logs. +Usage: simctl diagnose [-bX] [--timeout=] [--output=] [--no-archive] [--all-logs] [--data-containers] [--udid= [--udid= [...]]] + + -b Do NOT show the resulting archive in a Finder window upon completion. + -X Run all diagnostics with no timeout. It ignores the --timeout value if it is specified. + --timeout Specify a duration (in seconds) to wait for the log collection before timeout. + --output Specify the output directory. + If not provided the temporary directory is used. + --no-archive Do not create an archive, leave the collected files uncompressed. + --all-logs Include all device logs, even for non-booted devices. + --data-container Include booted device(s) data directory. + Warning: May include private information, app data containers, + and increases the size of the archive! + Default is NOT to collect the data container. + --udid Collect diagnostics only from the specified device. This option + may be specified more than once to consider multiple devices. + The --all-logs option causes all --udid options to be ignored. + +Please provide simctl diagnose output when filing bugs. + +NOTE: If there are booted devices only logs from those devices are collected by default, otherwise --all-logs is assumed. More information can be collected from a booted device so you should prefer leaving affected simulators booted when running simctl diagnose. + +NOTE: You can run 'simctl logverbose enable' to enable verbose logging and reboot the device before reproducing the problem and running 'simctl diagnose'. + + +xcrun simctl help logverbose +enable or disable verbose logging for a device +Usage: simctl logverbose [] (enable | disable) + The device. If not provided all booted devices are affected. + enable Enables verbose logging + disable Disables verbose logging + +NOTE: You may need to reboot the affected device before logging changes will be effective. + + +xcrun simctl help status_bar +Set or clear status bar overrides +Usage: simctl status_bar [list | clear | override ] + +Supported Operations: + list + List existing overrides. + + clear + Clear all existing status bar overrides. + + override + Set status bar override values, according to these flags. + You may specify any combination of these flags (at least one is required): + + --time + Set the date or time to a fixed value. + If the string is a valid ISO date string it will also set the date on relevant devices. + --dataNetwork + If specified must be one of 'hide', 'wifi', '3g', '4g', 'lte', 'lte-a', 'lte+', '5g', '5g+', or '5g-uwb'. + --wifiMode + If specified must be one of 'searching', 'failed', or 'active'. + --wifiBars + If specified must be 0-3. + --cellularMode + If specified must be one of 'notSupported', 'searching', 'failed', or 'active'. + --cellularBars + If specified must be 0-4. + --operatorName + Set the cellular operator/carrier name. Use '' for the empty string. + --batteryState + If specified must be one of 'charging', 'charged', or 'discharging'. + --batteryLevel + If specified must be 0-100. + + + +xcrun simctl help ui +Get or Set UI options +Usage: simctl ui