How to specify which device to use in the ios simulator

811 views
Skip to first unread message

Doug Cowley

unread,
Oct 1, 2014, 11:27:52 PM10/1/14
to rob...@googlegroups.com
Is there a way to specify which device to use when running "ios:launchIPhoneSimulator"?

I'd like to run my app on the iPhone 6 simulator but when using the gradle task or the Eclipse plugin's "run as iOS Simulator App", it is always launched on an iPhone 4 or 5 device.

I've seen the command:
ios-sim launch ios/build/robovm/Hoplite.app --timeout 90 --devicetypeid com.apple.CoreSimulator.SimDeviceType.iPhone-6 --args -rvm:log=warn

posted here but haven't had much success with it.  Which "ios-sim" binary should I be using?  I can't seem to find the one robovm uses.  Installing ios-sim v3 from here and running that command results in my app crashing at launch (even though it runs fine when launched from gradle or eclipse)

Paul Franceus

unread,
Oct 1, 2014, 11:58:52 PM10/1/14
to Doug Cowley, rob...@googlegroups.com
ios-sim is located in the robovm distribution in the bin directory along with robovm and ldid commands.

--
You received this message because you are subscribed to the Google Groups "RoboVM" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robovm+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Doug Cowley

unread,
Oct 2, 2014, 1:20:32 AM10/2/14
to rob...@googlegroups.com, dougc...@gmail.com, pa...@blueiris.us
Thanks.  I'm getting closer.

This is the command I'm running:

~/.m2/repository/org/robovm/robovm-dist/1.0.0-SNAPSHOT/unpacked/robovm-1.0.0-SNAPSHOT/bin/ios-sim launch ios/build/robovm/Hoplite.app --unbuffered required --timeout 90 --devicetypeid com.apple.CoreSimulator.SimDeviceType.iPhone-4s --args -rvm:log=warn

Which results in the error:

Session could not be started: Error Domain=NSPOSIXErrorDomain Code=3 "Unable to run app in Simulator" UserInfo=0x7fc449448360 {NSUnderlyingError=0x7fc449449d90 "Failed to lookup the process ID of com.magmafortress.hoplite after successful launch.  Perhaps it crashed after launch.", NSLocalizedFailureReason=An error was encountered while running (Domain = NSPOSIXErrorDomain, Code = 3), NSLocalizedDescription=Unable to run app in Simulator}

I've tried uninstalling the app from the simulator first and also "Reset Content and Settings...", neither of which make any difference.

The "Hoplite.app" I'm pointing to is the one generated by "gradle ios:createIPA" - is this correct?

I'm just trying to get this working in the iPhone 4s simulator now as that works correctly when run from "gradle ios:launchIPhoneSimulator" but I get the same error with any other device.

Ashley Williams

unread,
Oct 2, 2014, 5:28:51 PM10/2/14
to rob...@googlegroups.com, dougc...@gmail.com, pa...@blueiris.us
I don't think your devicetypeid is correct:

  --devicetypeid <device type>    The id of the device type that should be simulated (Xcode6+). Use 'showdevicetypes' to list devices.
                                  e.g "com.apple.CoreSimulator.SimDeviceType.Resizable-iPhone6, 8.0"

Doug Cowley

unread,
Oct 2, 2014, 7:54:01 PM10/2/14
to rob...@googlegroups.com, dougc...@gmail.com, pa...@blueiris.us
Thanks for the suggestion but this doesn't seem to make any difference.  

The devicetypeid argument I'm giving matches what is listed by "showdevicetypes" and the simulator launches the correct device.  It just fails to run my app.   (I've tried with and without the "8.0", too)

Doug Cowley

unread,
Oct 2, 2014, 11:07:58 PM10/2/14
to rob...@googlegroups.com, dougc...@gmail.com, pa...@blueiris.us
After poking around the source for a while I can answer my own question.

It was crashing because I was trying to the run the armv7 version of the app compiled for the device in the simulator, which requires the x86 version.

The ".app" is only generated when running createIPA, which confused me as I was looking for the .app "file" (actually a directory), after running launchIPhoneSimulator and couldn't find it.  The .app is just a copy of ios/build/robovm so the correct command becomes:

ios-sim launch ios/build/robovm/ --unbuffered --timeout 90 --devicetypeid com.apple.CoreSimulator.SimDeviceType.iPhone-6 --args -rvm:log=warn

Which works for me as long as I reset the simulator first

Paul Franceus

unread,
Oct 3, 2014, 1:42:31 AM10/3/14
to Doug Cowley, rob...@googlegroups.com
Awesome!

Philip Pilosi

unread,
Oct 7, 2014, 1:06:19 PM10/7/14
to rob...@googlegroups.com, dougc...@gmail.com, pa...@blueiris.us
I believe I am having the same issue you described, that I am trying to run the Armv7 binary instead of the x86 version. I am trying to have an Xcode6 Bot run a script that will install the app it just built into the simulator to run some instruments scripts on it. However, I'm not sure what I can do to change this since I am not using the same build method you are, any thoughts?

Doug Cowley

unread,
Oct 7, 2014, 6:56:45 PM10/7/14
to Philip Pilosi, rob...@googlegroups.com, pa...@blueiris.us
I was simply using the gradle ios:launchIPhoneSimulator task to build the x86 version of my app before running the command above.

It looks like the latest version of robovm-gradle-plugin now has support for specifying which device to use in the simulator so it's no longer required.

I suspect the easiest way to setup your scipt might be to create new gradle task that runs build(OS.ios, Arch.x86, TargetType.ios); to generate the app without installing it


Niklas Therning

unread,
Oct 8, 2014, 3:15:57 PM10/8/14
to Doug Cowley, Philip Pilosi, rob...@googlegroups.com, Paul Franceus
The latest gradle plugin and Eclipse plugin now has support for the Xcode 6 simulator and specifying device types, e.g. "iPhone5, 8.0". In Eclipse you can specify this in your iOS simulator launch configuration. With Gradle you can specify on the command line. See the README.md in the robovm-gradle-plugin repo for instructions: https://github.com/robovm/robovm-gradle-plugin
Reply all
Reply to author
Forward
0 new messages