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?
我使用iOS 4.2和Xcode 3.2.5创建了一个通用二进制文件。我正在尝试对应用程序进行一些自动化测试,因为iPad和iPhone版本之间的界面略有不同,我有单独的UIAutomation脚本。不幸的是,无论我做什么,当我点击Instruments中的记录按钮时,它总是使用iPad模拟器启动应用程序。如何强制Instruments启动iPhone模拟器?
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.
通用应用程序在所有3个模拟设备(iPhone,iPhone(Retina)和iPad)的模拟器中运行良好。我可以通过Xcode管理Active Executable,并且“Build and Run / Debug”工作正常,使用指定的模拟器正确。当我启动Instruments时,我选择iOS模拟器>全部>自动化,然后为iPhone选择我的自动化脚本,然后将目标设置为project-name / build / Debug-iphonesimulator / project-name。
4 个解决方案
#1
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:
根本不需要乱用你的应用程序:乐器允许你选择是否使用iPhone或iPad模拟器。假设您已经选择了自己的应用:
- Click the Target selector (currently displaying your app name).
- Click "Edit Active Target"
- Near the bottom, click the "Options" drop down.
- At the bottom of the list, you can select the "Simulator Configuration".
单击目标选择器(当前显示您的应用程序名称)。
点击“编辑活动目标”
在底部附近,点击“选项”下拉菜单。
在列表的底部,您可以选择“模拟器配置”。
#2
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:
在从命令行运行自动化之前,只需将以下内容传递给xcodebuild,即可创建通用应用程序的构建,该应用程序只是iPhone:
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
如果您想测试iPad,请在没有该构建选项的情况下进行另一次构建,然后仪器/模拟器将默认返回到iPad
For reference check out the docs for TARGETED_DEVICE_FAMILY here:
有关参考,请查看TARGETED_DEVICE_FAMILY的文档:
#3
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:
一个非常简单的解决方案是在启动自动化之前修改应用程序的Info.plist(无需重建应用程序)。使用PlistBuddy将UIDeviceFamily修改为适用于iPhone或iPad。例如:
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
#4
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.
我也遇到了这个问题,我注意到,因为无论我使用哪种运行设置,XCode都会显示模拟器 - 3.2,它应该在iPhone模拟器上为SDK版本显示4.0或4.1。
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.
我能够通过将“目标设备系列”设置更改为iPhone / iPad来修复它,因为它以某种方式设置为iPad。
#1
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:
根本不需要乱用你的应用程序:乐器允许你选择是否使用iPhone或iPad模拟器。假设您已经选择了自己的应用:
- Click the Target selector (currently displaying your app name).
- Click "Edit Active Target"
- Near the bottom, click the "Options" drop down.
- At the bottom of the list, you can select the "Simulator Configuration".
单击目标选择器(当前显示您的应用程序名称)。
点击“编辑活动目标”
在底部附近,点击“选项”下拉菜单。
在列表的底部,您可以选择“模拟器配置”。
#2
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:
在从命令行运行自动化之前,只需将以下内容传递给xcodebuild,即可创建通用应用程序的构建,该应用程序只是iPhone:
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
如果您想测试iPad,请在没有该构建选项的情况下进行另一次构建,然后仪器/模拟器将默认返回到iPad
For reference check out the docs for TARGETED_DEVICE_FAMILY here:
有关参考,请查看TARGETED_DEVICE_FAMILY的文档:
#3
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:
一个非常简单的解决方案是在启动自动化之前修改应用程序的Info.plist(无需重建应用程序)。使用PlistBuddy将UIDeviceFamily修改为适用于iPhone或iPad。例如:
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
#4
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.
我也遇到了这个问题,我注意到,因为无论我使用哪种运行设置,XCode都会显示模拟器 - 3.2,它应该在iPhone模拟器上为SDK版本显示4.0或4.1。
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.
我能够通过将“目标设备系列”设置更改为iPhone / iPad来修复它,因为它以某种方式设置为iPad。