Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to install iOS simulators from command line

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.

like image 718
Quanlong Avatar asked Dec 28 '15 12:12

Quanlong


People also ask

How can I launch the iOS simulator from terminal?

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.

How do I install Iphone simulator?

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.

Can I install iOS simulator without Xcode?

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.

Which command is used to run the app on iOS simulator?

Launch command is used to launch a application in your simulator device.


3 Answers

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

  • https://gist.github.com/masbog/bf6e2d6fce80447396eb
like image 85
Quanlong Avatar answered Oct 02 '22 22:10

Quanlong


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.

like image 32
RY_ Zheng Avatar answered Oct 03 '22 00:10

RY_ Zheng


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 :)

like image 29
ipraba Avatar answered Oct 03 '22 00:10

ipraba