Switching between devices in iOS simulator

@steve

It doesn’t matter which device you had active in Corona Simulator. 

The important thing is that you build for Xcode Simulator and set the SDK to 8.1 (or 8.0) when building. 

(I see that you’re Starter. I’m not sure if the public build might be a problem)

Also, It looks like you’re building a non-game app right?

Are you using any features that might only be available on an actual device?

I am using Xcode 6.0.1 (6A317) and had set the Xcode deployment target to 8.0.  The app only uses basic functionality such as audio (e.g. audio.play), sprite animation, and vector graphics using display.newRect, display.newImage, etc.  I was trying to use the Xcode simulator to display my app on the iPhone 6 and 6 plus.  I also noticed with this version of Xcode, I didn’t see an option for choosing the iPhone 6 (only the iPhone 6 plus).

If I can get this to work can I use the screenshots from the IOS simulator to submit as part of the App store submission?

If I can get this to work can I use the screenshots from the IOS simulator to submit as part of the App store submission?

You sure can. That’s what I do for devices I don’t own (i.e. iPhone 6 / 6 Plus).

It’s very simple and super-quick. Just use Command-S in the iOS simulator to take snapshot  :smiley: .

@ingemar

Did you see anything else that I may have missed which would cause this issue?  Like I said, it works fine for iPhone 5, but if I change it another device it does not work.  Also, where is the device option for iPhone 6 in the IOS  simulator?

@steve

No I can’t think of anything however I’m not sure if it has something to do with the public build or not.

It’s weird that the iPhone 6 is missing, but you should be able to add it back yourself.

• Start iOS simulator

• Choose Hardware->Device->Manage devices…

• Click ‘+’ in the lower left of the window

• Select the device-type and iOS version and click Create.

If you’re using the daily build (2393) and Xcode 6 there is an issue with apps running on the Xcode Simulator. Corona code signs the apps and it seems this now fails with Xcode 6. This has been fixed in our daily builds. If you’re having problems and can’t use the daily builds, you will need to wait for the next public release to use the Xcode Simulator. (We don’t  have a release date for the next release.)

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.