Instruments 总是为具有自动化功能的通用应用程序推出 iPad 模拟器,我如何强制它使用 iPhone 模拟器?
我使用 iOS 4.2 和 Xcode 3.2.5 创建了一个通用二进制文件。我正在尝试对应用程序进行一些自动化测试,由于 iPad 和 iPhone 版本之间的界面略有不同,因此我有单独的 UIAutomation 脚本。不幸的是,无论我做什么,当我单击 Instruments 中的录制按钮时,它总是使用 iPad 模拟器启动应用程序。如何强制 Instruments 启动 iPhone 模拟器?
该通用应用程序在所有 3 种模拟设备(iPhone、iPhone (Retina) 和 iPad)的模拟器中运行良好。我可以通过 Xcode 管理活动可执行文件,并且“构建和运行/调试”工作正常,可以正确使用指定的模拟器。当我启动 Instruments 时,我选择 iOS Simulator >全部>自动化,然后选择 iPhone 的自动化脚本,然后将目标设置为project-name/build/Debug-iphonesimulator/project-name。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
在从命令行运行自动化之前,只需将以下内容传递给 xcodebuild 即可创建通用应用程序(即 iPhone)的版本:
TARGETED_DEVICE_FAMILY=1
然后使用仪器运行自动化。
如果您想测试 iPad,请在没有该构建选项的情况下进行另一个构建,然后仪器/模拟器将默认返回 iPad
作为参考,请查看此处的 TARGETED_DEVICE_FAMILY 文档:
http://developer.apple.com/library/mac/#documentation/DeveloperTools/Reference/XcodeBuildSettingRef/1-Build_Setting_Reference/build_setting_ref .html
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
根本无需摆弄您的应用程序:Instruments 允许您选择是否使用 iPhone 或 iPad 模拟器。假设您已经选择了应用程序:
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:
一个非常简单的解决方案是在启动自动化之前修改应用程序的 Info.plist(无需重建应用程序)。使用 PlistBuddy 将 UIDeviceFamily 修改为适用于 iPhone 或 iPad。例如:
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:
我也遇到了这个问题,我注意到这一点,因为无论我使用哪种运行设置,XCode 都显示 Simulator - 3.2,而 iPhone 模拟器上的 SDK 版本本应显示 4.0 或 4.1。
我可以通过将“目标设备系列”设置更改为 iPhone/iPad 来修复此问题,因为它不知何故设置为仅 iPad。
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.