简体   繁体   English

乐器总是推出用于通用自动化应用程序的iPad模拟器,如何强制它使用iPhone模拟器?

[英]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. 我使用iOS 4.2和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. 我正在尝试对应用程序进行一些自动化测试,因为iPad和iPhone版本之间的界面略有不同,我有单独的UIAutomation脚本。 Unfortunately, no matter what I do, when I click the record button in Instruments, it always starts the application using the iPad simulator. 不幸的是,无论我做什么,当我点击Instruments中的记录按钮时,它总是使用iPad模拟器启动应用程序。 How can I force Instruments to launch the iPhone simulator? 如何强制Instruments启动iPhone模拟器?

The universal app runs fine in the simulator for all 3 simulated devices (iPhone, iPhone (Retina), and iPad). 通用应用程序在所有3个模拟设备(iPhone,iPhone(Retina)和iPad)的模拟器中运行良好。 I can govern the Active Executable via Xcode and "Build and Run/Debug" works fine, correctly using the simulator specified. 我可以通过Xcode控制Active Executable并使用指定的模拟器正确地“构建并运行/调试”工作正常。 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. 当我启动Instruments时,我选择iOS模拟器>全部>自动化,然后为iPhone选择我的自动化脚本,然后将目标设置为project-name / build / Debug-iphonesimulator / project-name。

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 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的文档:

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

No need to mess around with your app at all: Instruments allows you to select whether to use the iPhone or iPad simulator. 根本不需要乱用您的应用程序:仪器允许您选择是否使用iPhone或iPad模拟器。 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". 在列表的底部,您可以选择“模拟器配置”。

A very easy solution is to modify the Info.plist of your application before launching the automation (no need to rebuild the app). 一个非常简单的解决方案是在启动自动化之前修改应用程序的Info.plist(无需重建应用程序)。 Use PlistBuddy to modify the UIDeviceFamily to be either for iPhone or iPad. 使用PlistBuddy将UIDeviceFamily修改为iPhone或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

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。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM