Run iPhone/iPad Simulator for Continuous Integration

走远了吗. 提交于 2019-11-28 04:11:07
Erwin Coumans

Use the -SimulateApplication argument to run your executable in the simulator (executable inside the .app bundle)

(you could also compile the project from the command-line like this:) xcodebuild -project Test.xcodeproj -arch i386 -sdk iphonesimulator

Then for example:

/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone\ Simulator.app/Contents/MacOS/iPhone\ Simulator -SimulateApplication Test.app/Test

or

./Developer/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone Simulator.app/Contents/MacOS/iPhone\ Simulator -SimulateApplication Test.app/Test

To launch a specific device you can do:

/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone\ Simulator.app/Contents/MacOS/iPhone\ Simulator -SimulateDevice "iPhone Retina (3.5-inch)"

Try this in your shell for Xcode 6

osascript -e 'activate application "iOS Simulator"'

For Xcode 7

osascript -e 'activate application "Simulator"'
DShah

If you want to open Simulator with specific app installed then you can use some of the ready utility to launch simulator. This way it is easy to install the app and run on the simulator. This are the command line utilities that can be run from Terminal Window.

  1. iPhoneSim
  2. ios-sim
  3. Other are same as above two.

And main thing is all uses same approach to open simulator. (see the project for more details)

Other way (not recommended by me) use script file to run from command.

You can use xcrun simctl to list available simulators, launch applications, etc. This tool is present in both Xcode 7 and Xcode 8. If you don't give it a command it will print command line help.

xcrun simctl launch <UUID> <bundle id of app> will start the application.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!