It's a common case to run tests against different versions of iOS simulators/SDKs on CI. However, only the latest iOS simulator is installed by Xcode on default.
So I need install other missing iOS simulators from command line in CI environment. But I cannot find a way to install those simulators from command line.
Just type this command in Terminal: open -a Simulator. app to launch the most recent simulator. Type this command in Terminal to run the Simulator rigth from the its folder.
Simulator menu -> File -> New Simulator. It will show a list of iOS available for the device. 7. Select Device name -> Select Device model -> iOS version -> Create Simulator.
The Simulator app requires several other large directories from the Xcode distribution in order to work at all. The only official way to install all of those properly is to install the entire SDK from the dmg.
Launch command is used to launch a application in your simulator device.
For iOS 8.1 Simulator: http://devimages.apple.com/downloads/xcode/simulators/com.apple.pkg.iPhoneSimulatorSDK8_1-8.1.1.1434581536.dmg
For iOS 8.2 Simulator: http://devimages.apple.com/downloads/xcode/simulators/com.apple.pkg.iPhoneSimulatorSDK8_2-8.2.1.1434581536.dmg
For iOS 8.3 Simulator: http://devimages.apple.com/downloads/xcode/simulators/com.apple.pkg.iPhoneSimulatorSDK8_3-8.3.1.1434581536.dmg
For iOS 8.4 Simulator: http://devimages.apple.com/downloads/xcode/simulators/com.apple.pkg.iPhoneSimulatorSDK8_4-8.4.1.1435785476.dmg
I don't know where these URLs come from, but I found some clues
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.
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 :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With