Xcode
Xcode is a toolkit for MacOS made by Apple for Apple development.
It's best installed through their App Store page.
From there, you can install the Command Line Tools by:
- Open Xcode.
- Navigate to Preferences → Locations → Command Line Tools
- Select the most recent or otherwise relevant version.
After installation, to actually enable the Command Line Tools:
sudo xcode-select --reset
If you are on Apple Chip, you'll need to install Rosetta or else things will start breaking:
softwareupdate --install-rosetta --agree-to-license
After this, if you are missing xcrun
or simctl
, run the first launch experience with:
xcodebuild -runFirstLaunch
Platforms
Platforms in XCode refers to Apple operating systems that you can develop software for.
To install a new platform (like a new iOS version):
- Open Xcode.
- Navigate to Xcode → Settings → Components (used to be under Platforms)
- Recent platforms are available in the list automatically and are installable with the Get button. Older platforms are available by clicking the + button.
Managing platforms from the command line
To download all platforms:
xcodebuild -downloadAllPlatforms
To download a single platform (like if your iOS version is outdated)
xcodebuild -downloadPlatform iOS
Manually installing a platform
If all else fails, you can install platforms direct from DMG files downloadable from a browser.
Navigate to the Apple Developer downloads page.
From there you can download whichever runtime you need, then to add it after download:
xcrun simctl runtime add "/path/to/platform.dmg"
Simulators
Simulators are available for all Apple devices, and simulate hardware as best they can. They are not perfect, and are not performant or have feature parity against real devices.
# List available simulators
xcrun simctl list devices
To add a new simulator, say for iPhone 13, the steps are:
- Open XCode.
- Navigate to Window → Devices and Simulators → Simulators → +.
- Select the device type, in this case iPhone 13.
Runtimes
# Update the local iOS SDK version
xcodebuild -downloadPlatform iOS
# Get runtimes
xcrun simctl runtime list
# Get runtime IDs
xcrun simctl runtime list --json | jq ".[] | .identifier" --raw-output
# Get iPhone devicetypes
xcrun simctl list devicetypes --json |\
jq -c '.[].[] | select(.productFamily | contains("iPhone")) | .name'
Push notifications
Send a push notification to a running simulator:
xcrun simctl push booted com.example.MyApp payload.json