Instruments 总是为具有自动化功能的通用应用程序推出 iPad 模拟器,我如何强制它使用 iPhone 模拟器?

发布于 2024-10-06 03:01:52 字数 460 浏览 0 评论 0原文

我使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

帅冕 2024-10-13 03:01:52

在从命令行运行自动化之前,只需将以下内容传递给 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

策马西风 2024-10-13 03:01:52

根本无需摆弄您的应用程序:Instruments 允许您选择是否使用 iPhone 或 iPad 模拟器。假设您已经选择了应用程序:

  1. 单击目标选择器(当前显示您的应用程序名称)。
  2. “编辑活动目标”
  3. 单击底部附近的
  4. ,单击“选项”下拉列表。在列表底部,您可以选择“模拟器配置”。

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".
吲‖鸣 2024-10-13 03:01:52

一个非常简单的解决方案是在启动自动化之前修改应用程序的 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

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
别理我 2024-10-13 03:01:52

我也遇到了这个问题,我注意到这一点,因为无论我使用哪种运行设置,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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文