How to install iOS simulators from command line
FYI
All simulators are packed with Xcode app. Instead of installing simulators you can just install the specific Xcode versions. Xcode7.0 has iOS9 Simulators Xcode6.4 has iOS8.x Simulators
In your CI testing if you want to test you app for a specific simulator just select xcode version before you do the xcodebuild command
xcode-select -switch <path to your xcode app>
This will set your default xcode to run the xcodebuild Then run the xcodebuild with your respective simulator.
xcodebuild -configuration ${BUILD_TYPE} -target ${TARGET_NAME} -arch ${CPU_ARCHITECTURE} -sdk ${SIMULATOR_OR_IOS_SDK}
In the place of SIMULATOR_OR_IOS_SDK
give your simulator value.
You can find the simulator value by running
xcodebuild -showsdks
This will show like
OS X SDKs:
OS X 10.11 -sdk macosx10.11
iOS SDKs:
iOS 9.1 -sdk iphoneos9.1
iOS Simulator SDKs:
Simulator - iOS 9.1 -sdk iphonesimulator9.1
tvOS SDKs:
tvOS 9.0 -sdk appletvos9.0
tvOS Simulator SDKs:
Simulator - tvOS 9.0 -sdk appletvsimulator9.0
watchOS SDKs:
watchOS 2.0 -sdk watchos2.0
watchOS Simulator SDKs:
Simulator - watchOS 2.0 -sdk watchsimulator2.0
This way you can build your project on any specific device/simulator/os.
Hope this helps :)
It can be done with xcode-install, with the following commands
gem install xcode-install
xcversion simulators --install='iOS 9.3'
xcrun simctl create <name> <device type> <runtime>
For example:
xcrun simctl create "ry" "iPhone 11 Pro Max" iOS13.3
xcrun simctl
is command utils to control iOS simulator, just like adb
for Android. You can also run xcrun simctl help
, there are a bundle of useful subcommands. When successful, most of these commands exit with 0; when failed, most exit with a non-zero number.
Personally, I have an article about how to use simulator from terminal.