测试时如何更改默认的 Xcode iphone 模拟器
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3643298/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to change the default Xcode iphone simulator when testing
提问by Howard
I don't know why but now the default iphone simulator launched when I build the project is "ipad", but I want it to use iphone 3g instead.
我不知道为什么,但现在我构建项目时启动的默认 iphone 模拟器是“ipad”,但我希望它改用 iphone 3g。
Any way to set this preference?
有什么办法可以设置这个偏好?
采纳答案by juckobee
For me works changing active SDK from 3.2 to 4.0. If your project is mentioned to work on iPad and iPhone (or for compatibility matters) I believe the only way is manually switching active executable before running your app on simulator. Apple:"iPhone OS 3.2 does not support iPhone and iPod touch devices. It runs only on iPad.".
对我来说,将活动 SDK 从 3.2 更改为 4.0。如果提到您的项目可以在 iPad 和 iPhone 上运行(或出于兼容性问题),我相信唯一的方法是在模拟器上运行您的应用程序之前手动切换活动的可执行文件。Apple:“iPhone OS 3.2 不支持 iPhone 和 iPod touch 设备。它只能在 iPad 上运行。”。
回答by D Kavitha Vijay Datchnamoorthy
In Xcode,
在Xcode中,
Click Product -> Destination -> iOS Simulator -> Choose Device to run.
单击产品 -> 目标 -> iOS 模拟器 -> 选择要运行的设备。
Then build and execute Xcode project.
然后构建并执行 Xcode 项目。
It works..
有用..
回答by Android dev
Go to Hardware > Device from simulator menu.
从模拟器菜单转到硬件 > 设备。
回答by David Scott
You can select the device from the menu inthe simulator.
您可以从模拟器的菜单中选择设备。
回答by Gary Tsui
Try Project > Active Executable , and select the one you want the most.
尝试 Project > Active Executable ,然后选择您最想要的一个。
回答by Questor
None of the above worked for me, but the following took care of the issue :
以上都不适合我,但以下解决了这个问题:
Source:http://www.cocoabuilder.com/archive/xcode/301182-xcode-3-2-6-keeps-switching-to-ipad-simulator.html
来源:http : //www.cocoabuilder.com/archive/xcode/301182-xcode-3-2-6-keeps-switching-to-ipad-simulator.html
Excerpt:
摘抄:
This works for XCode 3.2.6. I don't yet use XCode 4.x so don't know if this will work for it or not. I would also quit XCode before doing this, just in case.
Go to the project folder and find the .xcodeproj file. Right-click (or Control-click) it and select Show Package Contents. When the package contents window appears, find the .pbxuser file (there might be multiple such files if the project was worked on by multiple folks and/or multiple computers). Open this file, which is XML, in your preferred text editor. Find the section with the comment "/* Project object */". There is most likely not a line in that section for the key "activeSDKPreference". If there is no such key, add the following:
activeSDKPreference = iphonesimulator4.2;
I found it after the "activeExecutable" key in that section, so I've been adding it in that same order.
If there is already an "activeSDKPreference" entry, change it to "iphonesimulator4.2".
Close the editor and the package contents window and then double click the .xcodeproj file to reopen the project. Now you should have entries for iPhone Simulator 4.2 and iPad Simulator 4.2 in the project settings pull down menu, with iPhone Simulator 4.2 probably already checked.
这适用于 XCode 3.2.6。我还没有使用 XCode 4.x,所以不知道这是否适用。我也会在这样做之前退出 XCode,以防万一。
转到项目文件夹并找到 .xcodeproj 文件。右键单击(或按住 Control 单击)它并选择显示包内容。当包内容窗口出现时,找到 .pbxuser 文件(如果项目由多人和/或多台计算机处理,则可能有多个此类文件)。在您首选的文本编辑器中打开此文件,即 XML。找到带有注释“/* Project object */”的部分。该部分中很可能没有一行用于关键“activeSDKPreference”。如果没有这样的键,请添加以下内容:
activeSDKPreference = iphonesimulator4.2;
我在该部分的“activeExecutable”键之后找到了它,所以我一直以相同的顺序添加它。
如果已经有“activeSDKPreference”条目,请将其更改为“iphonesimulator4.2”。
关闭编辑器和包内容窗口,然后双击 .xcodeproj 文件重新打开项目。现在您应该在项目设置下拉菜单中有 iPhone Simulator 4.2 和 iPad Simulator 4.2 的条目,iPhone Simulator 4.2 可能已经被选中。
Additional Notes:
补充说明:
1) In my particular case, my entry in .pbxuser file had said iphonesimulator4.3, even though under Project-Project Settings menu it said iphonesimulaor4.2!. However, once I changed it to iphonesimulator4.2 in the .pbxuser file it stop auto selecting iPad all the time.
2) If you use SVN you will not see an "M" in SVN column showing that you changed the project (even if you refresh/update). However, just do a "Commit Entire Project" and your changes to .pbxuser file will get updated. I also suggest referencing this post in your check-in comment in case you ever need to change it back for whatever reason.
1) 在我的特殊情况下,我在 .pbxuser 文件中的条目说的是 iphonesimulator4.3,即使在项目-项目设置菜单下它说的是 iphonesimulaor4.2!。但是,一旦我在 .pbxuser 文件中将其更改为 iphonesimulator4.2,它就会一直停止自动选择 iPad。
2) 如果您使用 SVN,您将不会在 SVN 列中看到一个“M”,表明您更改了项目(即使您刷新/更新)。但是,只需执行“提交整个项目”,您对 .pbxuser 文件的更改就会得到更新。我还建议您在签到评论中引用这篇文章,以防您因任何原因需要将其改回。
回答by amacrobert
In the chance that anyone reading this is building their app in react-native, the solution is the --simulator option.
如果任何阅读本文的人都在用 react-native 构建他们的应用程序,那么解决方案是 --simulator 选项。
For example:
例如:
$ react-native run-ios --simulator "iPhone X"
回答by puchikon
I finally solved this problem myself.
我终于自己解决了这个问题。
First, install new version of xCode, which is xCode 4.
首先,安装新版本的 xCode,即 xCode 4。
Then set project scheme to iphone simulator and run app in xCode several times.
然后将项目方案设置为 iphone 模拟器并在 xCode 中多次运行应用程序。
And re-install xCode 3 and the problem will be gone away!
并重新安装 xCode 3,问题就会消失!
回答by Panagiotis
For XCode Version 3.2.6 the following helps: Project->Active Executable->iPhone Simulator 4.3
对于 XCode 3.2.6 版,以下帮助:Project->Active Executable->iPhone Simulator 4.3
I don't know if it is working for newer XCode environments. Gary Tsui has also pointed out this approach previously.
我不知道它是否适用于较新的 XCode 环境。Gary Tsui 之前也指出过这种方法。
回答by Martin
Yes, it's annoying. This worked for me: Open the .plist file in group/folder resources and check the checkbox for key "Application requires iPhone environment".
是的,这很烦人。这对我有用:在组/文件夹资源中打开 .plist 文件并选中“应用程序需要 iPhone 环境”键的复选框。