Recently I had to generate an iOS simulator build for our QA team so that they can run automated tests. This is very handy and convenient because once simulator build is generated you can launch it on any ios simulator on other Mac machines without dealing with certificates or provisioning profiles. Which is useful for things like quick tests that can be done on a simulator, simple demos to a client, facebook app submission reviews, automated QA test, etc.
There’s a very nice command tool that allows controlling the ios simulators called ios-sim.
“The ios-sim tool is a command-line utility that launches an iOS application on the iOS Simulator. This allows for niceties such as automated testing without having to open Xcode.”
ios-sim repository
In this article will show you a step by step guide on how to generate the simulator build and launch it on an iOS simulator using the tool mentioned above.
Let’s start!
1- Install ios-sim using npm:
npm install ios-sim -g
2- On Visual Studio run your application on an iOS Simulator
Once the application is launched in the ios simulator it generates a build located at the following relative path: [Your iOS Project Folder]/bin/iPhoneSimulator/Debug/device-builds
There could be multiple folders if you previously launched the application on other simulators. Just go inside the folder that has the name of the simulator you just launched and grab the [YourAppName].app file
With this file, you can run the application on any iOS simulator that is compatible with (No provisioning profiles needed for that 😛 )
3 – Launch the application on an iOS Simulator
You can launch this build on any installed ios simulators. You can get the list of all simulators installed by using the following command:
ios-sim showdevicetypes
To launch the generated build on the simulator we use :
ios-sim launch [Path To Your Application/YourAppName.app] –devicetypeid com.apple.CoreSimulator.SimDeviceType.[Name of device type]
For example, if in the Terminal you are located at the exact path where the simulator build file is located and it’s called SimSample.iOS.app. To run it on iPhone X will be using the following command:
ios-sim launch SimSample.iOS.app --devicetypeid com.apple.CoreSimulator.SimDeviceType.iPhone-X
4 – ZIP simulator build
In case you want to use this build for something like facebook application review submission or automated QA testing, you can compress it by using the following command:
ditto -ck --sequesterRsrc --keepParent `ls -1 -d -t SimSample.iOS.app | head -n 1` SimSample.iOS.zip
Note: In this case, my build name is SimSample.iOS.app so change it for your application simulator build name.
References
https://github.com/ios-control/ios-sim
https://robgibbens.com/easily-launch-the-ios-simulator-from-the-command-line/
http://simulatorbuild.blogspot.com/p/generate-simulator-build-in-order-to.html
https://developers.facebook.com/docs/ios/getting-started/advanced
https://gist.github.com/DorkNstein/3391de84aeca015dc48ff97edc156b46
Happy build simulation!