ios Xcode可以构建项目但不能在模拟器上运行
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7800229/
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
Xcode can build a project but can't run it on simulator
提问by Eugene Chumak
When I download a project from the web, sometimes it can be built but doesn't run (XCode -> Product -> Run is disabled, in grey). This never happens when I create projects myself. What could be the problem? Is it somehow connected with version? I'm new to iOS development and download projects from the web for studying purposes. It's a pity not to be able to test them on the simulator.
当我从 Web 下载项目时,有时它可以构建但无法运行(XCode -> Product -> Run 已禁用,呈灰色)。当我自己创建项目时,这永远不会发生。可能是什么问题呢?它与版本有某种联系吗?我是 iOS 开发的新手,为了学习目的从网上下载项目。很遗憾不能在模拟器上测试它们。
回答by
Generally, if you can't Run a project, either:
一般来说,如果你不能运行一个项目,要么:
It doesn't have a build scheme that knows how to "run". Check at the top next to the Run/Stop buttons that there's a profile name and target device shown. If the box says
No Scheme
then click on it and create a New Scheme. If there IS a scheme, click on the drop-down menu (left divider in Xcode 4.2+, anywhere on the box otherwise) and go to Edit Scheme to make sure the scheme was set up correctly for RunningIt doesn't have a build configuration set. You should see this in the Run section of your build scheme. Check there's one selected. If the list is empty, go to the Project icon at the top of the leftmost pane, select the Project, go into the Info section, and create a build configuration, although there should already be at least one if you can build the project
It doesn't have a runnable target at all, which might mean you've got a project which compiles to a static library or framework for use in OTHER projects. If this is the case, you should see the icon for your build Target as a yellow toolbox (framework), or a little white building (a "library", although to me it looks more like the United States Supreme Court Building).
The target isn't valid for the Simulator, which means you might need to add
i386
to the list of Architecturesand Valid Architectureson the Target before you can run itThe target isn't valid for the currently connected device. For this one, check the Deployment Target number is set back enough to be valid for the device's version of
iOS
Xcode can't see the connected device. Try unplugging and plugging it back in. If it still doesn't recognize it, you may have not added it to Xcode (Window -> Devices -> Select the device -> Use for Development)
它没有知道如何“运行”的构建方案。检查运行/停止按钮旁边的顶部是否显示了配置文件名称和目标设备。如果该框显示,
No Scheme
则单击它并创建一个新方案。如果有方案,请单击下拉菜单(Xcode 4.2+ 中的左分隔符,否则框上的任何位置)并转到编辑方案以确保方案已正确设置为运行它没有构建配置集。您应该在构建方案的运行部分看到这一点。检查是否选择了一个。如果列表为空,请转到最左侧窗格顶部的“项目”图标,选择“项目”,进入“信息”部分,然后创建一个构建配置,但如果您可以构建该项目,则应该至少有一个
它根本没有可运行的目标,这可能意味着您有一个项目可以编译为静态库或框架以用于其他项目。如果是这种情况,您应该将构建目标的图标视为黄色工具箱(框架)或白色小建筑(“图书馆”,虽然对我来说它看起来更像美国最高法院大楼)。
目标对 Simulator 无效,这意味着您可能需要先添加
i386
到目标上的体系结构和有效体系结构列表中,然后才能运行它目标对当前连接的设备无效。对于这一点,检查部署目标编号是否设置回足以对设备的版本有效
iOS
Xcode 看不到连接的设备。尝试拔下并重新插入。如果它仍然无法识别它,您可能没有将它添加到 Xcode(窗口 -> 设备 -> 选择设备 -> 用于开发)
回答by luoser
Make sure that in your Edit Scheme (click on your project name next to stop button -> Edit Scheme), in the Info tab of the Run menu selection, that your .app is selected as the Executable. I had this issue and "None" was selected, happened after refactoring the project's name and reconfiguring the build targets.
确保在您的编辑方案中(单击停止按钮旁边的项目名称 -> 编辑方案),在运行菜单选择的信息选项卡中,您的 .app 被选为可执行文件。我遇到了这个问题并且选择了“无”,这是在重构项目名称并重新配置构建目标之后发生的。
回答by john fantasy
you may download a project that the deployment setting (the ios version) is higher than the one your xcode support. if this is your situation, you has two options to sovle the problem.
您可能会下载一个部署设置(ios 版本)高于您的 xcode 支持的项目。如果这是您的情况,您有两种选择来解决问题。
try run the project in a older deployment option. follow these instructions ( if the project just setting to a higher version but not using any feature of the higher version. this approach should work): select project file in xcode > select the target you are going to run > select summary tab > in section 'iOS Application Target' > in the combo box about 'Deployment Target' select the version that your Xcode support. and then you could select and run the project in the simulator.
if the project dose use features in the higher version, then you should update your Xcode in order to run the project.
尝试在较旧的部署选项中运行该项目。按照这些说明(如果项目只是设置为更高版本但不使用更高版本的任何功能。这种方法应该有效):在 xcode 中选择项目文件 > 选择您要运行的目标 > 选择摘要选项卡 > 在部分“iOS 应用程序目标”> 在关于“部署目标”的组合框中选择您的 Xcode 支持的版本。然后您可以在模拟器中选择并运行该项目。
如果项目使用了更高版本中的功能,那么您应该更新您的 Xcode 以运行该项目。
Hope this helps!
希望这可以帮助!
回答by Anton Malyshev
In my case the issue was really simple, I needed to check "Launch: Automatically" check in "Product > Scheme > Edit scheme > Run" menu.
就我而言,问题非常简单,我需要在“产品 > 方案 > 编辑方案 > 运行”菜单中检查“启动:自动”检查。
When this setting wasn't checked I cannot find App icon in simulator to launch application.
未选中此设置时,我无法在模拟器中找到应用程序图标来启动应用程序。
回答by Hitesh Rajyaguru
In My Case Sole by Go->Project->Architectures->Architecture=select standard architectures(armv7,arm64)...
在 My Case Sole 中,Go->Project->Architectures->Architecture=select standard architectures(armv7,arm64)...
same as
与...一样
Go->Target->Architectures->Architecture=select standard architectures(armv7,arm64)...
Go->Target->Architectures->Architecture=选择标准架构(armv7,arm64)...