Switching between devices in iOS simulator

I can now build for xCode simulator but I can’t figure out how to test in different devices. It launches the simulator in iPhone 4s mode and all is OK, I then go to Hardware -> Device and choose something else. That simulator is then launched but my app is no longer available. It’s not installed on that simulator.

I don’t remember it working like this before, or am I forgetting some step?

It seems like Apple changed a whole bunch of things with iOS 8!
 
As I remember it didn’t used to be like this either, but now all Xcode simulator devices are independent. It looks like compiled apps need to be installed on each “device” individually.

First you need the UDID of the device you want to start. The UDID of each device is different. To get a list of valid UDID strings for each device, type:

xcrun simctl list

At the end of the output you’ll see a bunch of UDID strings for each device. Use one of these UDIDs in place of the UDID-of-device in the command below.

 
The command to start the Xcode simulator from the command line is:

open -a "iOS Simulator" --args -CurrentDeviceUDID UDID-of-device

 
I haven’t tried installing apps with external commands into specific Xcode simulators. All my projects are Enterprise which means I use Xcode to select which simulator to start.

EDIT:

I’ve included some instructions in a post further down on how to install and launch apps in the Xcode simulator of choice.

Hopefully these instructions might be useful  :slight_smile:

Thanks Ingemar.

Do you know if its possible to include the .app file in that command so it installs? Google is not turning up with anything recent.

BTW reported it, Case 36040.

To install an app via the command line do the following:

  1. Launch the Xcode simulator and select the device type you want to test your app on

  2. In Terminal, go to the folder where your Corona Xcode Simulator compiled app is located. Type

    xcrun simctl install booted ./name-of-your-app-bundle.app

  3. To launch the app (replace com.company.appname with your app’s bundle id)

    xcrun simctl launch booted com.company.appname

Hope this helps…

That did the trick, thanks!

Some interesting commands here for controlling the Xcode simulator:

xcrun simctl help

Usage: simctl [--noxpc] [--set \<set path\>] \<subcommand\> ... | help [subcommand] Command line utility to control the iOS Simulator For subcommands that require a \<device\> argument, you may specify a device UDID or the special "booted" string which will cause simctl to pick a booted device. If multiple devices are booted when the "booted" device is selected, simctl will choose one of them. Subcommands: create Create a new device. delete Delete a device. erase Erase a device's contents and settings. boot Boot a device. shutdown Shutdown a device. rename Rename a device. getenv Print an environment variable from a running device. openurl Open a URL in a device. addphoto Add a photo to the photo library of a device. install Install an app on a device. uninstall Uninstall an app from a device. launch Launch an application by identifier on a device. spawn Spawn a process on a device. list List available devices, device types, or runtimes. notify\_post Post a darwin notification on a device. icloud\_sync Trigger iCloud sync on a device. help Prints the usage for a given subcommand.

simctl is new in Xcode 6 and we’re taking a look to see what features we can leverage.

It does appear that the sandboxing in the Xcode 6 iOS Simulator is determined by combinations of device model and operating system version (amongst other things) so, for now, you’ll need to switch your Corona Simulator skin to the device you want in the Xcode iOS Simulator and then build for device.

I did a quick test with a native Xcode 6 app and targeted the iOS Simulator iPhone 6. After the app loaded in the iOS Simulator, I switched devices to iPhone 6 Plus (in the iOS Simulator) and my test app was no longer available. This is independent of Corona and shows that Apple has changed how the iOS Simulator works. Most native developers change their target device in Xcode and rebuild so they don’t run into this issue.

As Perry mentioned above, you can select the iOS device you want to run in the IOS Simulator by selecting that skin in Corona SDK before building for the Xcode Simulator.

Tom, your method does not appear to work with db 2014.2451 on OS 10.10. I built “for the 6+” but it still defaults to the 4S on launch of the iOS Simulator.

Do you have Xcode 6 installed?  Is it the default Xcode?

@mort,

You’re right about it not working with build 2451. Our engineer fixed a bug with borderless skins and must have broke it for regular skins. I flagged the bug so it can be fixed. I do know that build 2449 does work correctly using the iPhone 6 or 6+ skins when building for Xcode Simulator.

Thanks for letting us know.

@ Rob, Whoops! Yes, 6.0.1 is the default version of Xcode installed. @Tom, You’re welcome. 

This still doesn’t appear to be fixed. Am I missing something in regards to the latest daily builds?

EDIT: It appears to be an issue (again) with xCode 6. 1. 

6.0. appears to  work.

@Rob, You’re correct. CoronaSim really needs the reported resolution for the 6+ to be the pre-scaled resolution, not 1920*1080.

Xcode 6.0.1

Corona SDK 2014.2458

We’re back to it not working for borderless skins.

When building for Xcode simulator, it uses the correct device if the last used setting in Corona was skinned, but when a borderless setting was used it always chooses the iPhone 4S.

Mort, 1080x1920 is correct for OpenGL based apps which is what Corona Labs makes.  The 1242x2208 is correct for UIKit apps, which the Xcode simulator assumes your doing UIKit.

Rob

Hmmm, it’s working for me.

What do you see in your console when the iOS Simulator starts?  Something like:

Using Xcode iOS Simulator from Xcode 6.0.1 + '/Applications/CoronaSDK/Corona Simulator.app/Contents/Resources/ios-sim' launch /Users/perry/Desktop/StatusBarTest.app --devicetypeid 'com.apple.CoreSimulator.SimDeviceType.iPhone-6, 8.0'

@Perry

I was having this problem for while but didn’t really mind. I hardly reboot my Mac, but I installed Yosemite GM candidate 2 on my Mac today and after rebooting everything works.

@Rob, Okay. Thanks for the distinction. I likely misread what you posted in the other thread. In any case, I’m glad I now know why the two solutions act differently. 

Does it matter what device you built for in the Corona Simulator?  In the Corona simulator I chose the iPhone 5 and built for XCode.  I followed your commands and was able to launch Xcode simulator for 6 plus device.  I also see my app on the screen.  When I click on my App it begins to Open and correctly shows my launch image but then shuts down.  In looking at the system logs I see the following:

Oct 22 17:25:02 — last message repeated 1 time —

Oct 22 17:25:02 sdgl12893de4e assertiond[1243]: assertion failed: 13F34 12A365: assertiond + 11619 [03CE1BE5-ACCB-3989-A453-41D167A25E66]: 0x1

Oct 22 17:25:02 sdgl12893de4e com.apple.CoreSimulator.SimDevice.906302C8-1E39-4A04-B581-D2CD760416E2.launchd_sim[1228] (com.apple.imfoundation.IMRemoteURLConnectionAgent): The _DirtyJetsamMemoryLimit key is not available on this platform.

Oct 22 17:25:02 sdgl12893de4e joggingtrainer[1445]: assertion failed: 13F34 12A365: libxpc.dylib + 59417 [75E30F22-514B-3A20-B82C-EDA43AF5C35C]: 0x7d

Oct 22 17:25:02 sdgl12893de4e assertiond[1243]: assertion failed: 13F34 12A365: assertiond + 11619 [03CE1BE5-ACCB-3989-A453-41D167A25E66]: 0x1

Oct 22 17:25:02 sdgl12893de4e.local.tld SpringBoard[1239]: [MPUSystemMediaControls] Updating supported commands for now playing application.

Oct 22 17:25:02 sdgl12893de4e com.apple.CoreSimulator.SimDevice.906302C8-1E39-4A04-B581-D2CD760416E2.launchd_sim[1228] (UIKitApplication:com.capievideo.joggingtrainer[0xdf7d][1445]): Service exited with abnormal code: 1

Is there anything that I am missing to do here?