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

4

7

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.

Perversion answered 3/12, 2010 at 20:53 Comment(0)
D
5

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".
Devisable answered 12/3, 2013 at 0:39 Comment(2)
THIS is the solution I was looking for. You see a list of all available simulators, and you select the correct one. Done.Winograd
This is the correct answer. I would add that a slightly more direct approach is: Target Menu (showing name of app) > Options and choose the desired Simulator Configuration without having to open any dialogs.Handcart
B
9

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

Boadicea answered 18/11, 2011 at 4:8 Comment(0)
D
5

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".
Devisable answered 12/3, 2013 at 0:39 Comment(2)
THIS is the solution I was looking for. You see a list of all available simulators, and you select the correct one. Done.Winograd
This is the correct answer. I would add that a slightly more direct approach is: Target Menu (showing name of app) > Options and choose the desired Simulator Configuration without having to open any dialogs.Handcart
T
4

A very easy solution is to modify the Info.plist of your application before launching the automation (no need to rebuild the app). Use PlistBuddy to modify the UIDeviceFamily to be either for iPhone or iPad. For example:

plistbuddy="/usr/libexec/PlistBuddy"
plistfile="$myapp/Info.plist"
if [ $device == "iphone" ]; then
 uidevicefamily=1
else
 uidevicefamily=2
fi
$plistbuddy -c "Delete :UIDeviceFamily" $plistfile
$plistbuddy -c "Add :UIDeviceFamily array" $plistfile
$plistbuddy -c "Add :UIDeviceFamily:0 integer $uidevicefamily" $plistfile
Twister answered 22/3, 2012 at 16:46 Comment(0)
F
1

I was having problems with this as well, which I noticed because no matter which run settings I was using, XCode was displaying Simulator - 3.2, when it should have shown 4.0 or 4.1 for the SDK version on the iPhone simulator.

I was able to fix it by changing the "Target Device Family" setting over to iPhone/iPad, as it somehow was set to just iPad.

Fallible answered 7/12, 2010 at 1:11 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.