Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Instruments always launches iPad Simulator for Universal Apps with Automation, how can I force it to use the iPhone Simulator?

I've created a universal binary using iOS 4.2 and Xcode 3.2.5. I'm trying to do some automation testing on the application and since the interfaces are slightly different between the iPad and iPhone versions, I have separate UIAutomation scripts. Unfortunately, no matter what I do, when I click the record button in Instruments, it always starts the application using the iPad simulator. How can I force Instruments to launch the iPhone simulator?

The universal app runs fine in the simulator for all 3 simulated devices (iPhone, iPhone (Retina), and iPad). I can govern the Active Executable via Xcode and "Build and Run/Debug" works fine, correctly using the simulator specified. When I launch Instruments I'm choosing iOS Simulator > All > Automation, then selecting my automation script for the iPhone and then setting the target as project-name/build/Debug-iphonesimulator/project-name.

like image 288
smountcastle Avatar asked Dec 03 '10 20:12

smountcastle


People also ask

How do I add iPad simulator to Xcode?

If you require a different version of the iOS simulator than is provided by your Xcode installation, you can download additional simulators in Xcode. Open Xcode and click Menu > Xcode > Preferences > Select Components, and then choose the simulator version you want to download.

How to run app in iPhone from Xcode?

You may connect a real device to your Mac using a cable, or for iOS or tvOS apps, connect it over Wi-Fi after you pair it with Xcode. For macOS apps, choose a scheme, then click the Run button in the toolbar. You can also run SwiftUI apps in the simulator or on a device using the controls in the preview.

How to run Xcode project on iPhone simulator?

To run your app in Simulator, choose an iOS simulator—for example, iPhone 6 Plus, iPad Air, or iPhone 6 + Apple Watch - 38mm—from the Xcode scheme pop-up menu and click Run. Xcode builds your project and then launches the most recent version of your app running in Simulator on your Mac screen, as shown in Figure 1-1.

How do you force quit an app on simulation?

⌘ + Shift + H (twice) It is important that you press the H key two times in a row to imitate the double tap correctly. Afterwards, you can see the screenshots of all running apps, which can be clicked with the mouse for opening them.


2 Answers

Before running your automation from the command line create a build of your universal app that is iPhone only by passing the following to xcodebuild:

TARGETED_DEVICE_FAMILY=1

Then run your automation using instruments.

If you want to then test iPad, make another build without that build option and then instruments / simulator will default back to iPad

For reference check out the docs for TARGETED_DEVICE_FAMILY here:

http://developer.apple.com/library/mac/#documentation/DeveloperTools/Reference/XcodeBuildSettingRef/1-Build_Setting_Reference/build_setting_ref.html

like image 52
MayorJustin Avatar answered Oct 03 '22 23:10

MayorJustin


No need to mess around with your app at all: Instruments allows you to select whether to use the iPhone or iPad simulator. Assuming you've already selected your app:

  1. Click the Target selector (currently displaying your app name).
  2. Click "Edit Active Target"
  3. Near the bottom, click the "Options" drop down.
  4. At the bottom of the list, you can select the "Simulator Configuration".
like image 45
Jacob Lukas Avatar answered Oct 03 '22 23:10

Jacob Lukas