Xcode可以构建项目,但不能在模拟器上运行

时间:2023-01-24 18:30:39

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 ->产品->运行是禁用的,在灰色中)。当我自己创建项目时,这种情况从未发生过。有什么问题吗?它是否与版本有关?我是iOS开发的新手,为了学习目的,我从网上下载项目。遗憾的是不能在模拟器上测试它们。

5 个解决方案

#1


88  

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 Running

    它没有一个知道如何“运行”的构建方案。在运行/停止按钮旁边的顶部检查是否显示了配置文件名称和目标设备。如果box表示没有计划,那么点击它并创建一个新方案。如果有一个scheme,单击下拉菜单(Xcode 4.2+中的左分隔符,框中的任何地方没有),然后进入Edit scheme以确保该scheme已正确设置为运行

  • It 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

    它没有构建配置集。您应该在构建方案的运行部分看到这一点。检查有一个选择。如果列表为空,请转到最左边窗格顶部的项目图标,选择项目,进入Info部分,并创建构建配置,尽管如果可以构建项目,至少应该有一个

  • 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 Architectures and Valid Architectures on the Target before you can run it

    目标对模拟器无效,这意味着您可能需要将i386添加到目标上的体系结构和有效体系结构列表中,然后才能运行它

  • The 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

    目标对当前连接的设备无效。对于这个,检查部署目标号是否被设置到足以对设备版本的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)

    Xcode看不到连接的设备。试着拔掉插头并把它插回去。如果它仍然不能识别它,您可能还没有将它添加到Xcode(窗口->设备->选择设备->用于开发的设备)

#2


29  

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.

请确保在您的编辑方案中(单击stop按钮旁边的项目名称—>编辑方案),在Run菜单选择的Info选项卡中,您的.app被选择为可执行文件。我遇到了这个问题,在重构项目名称并重新配置构建目标之后,选择了“None”。

#3


4  

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支持。如果这是你的情况,你有两个选择来解决这个问题。

  1. 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.

    尝试在旧的部署选项中运行项目。遵循以下说明(如果项目只是设置为更高版本,而没有使用更高版本的任何特性)。这个方法应该是有效的):在xcode >中选择项目文件,选择要运行>的目标,在“iOS应用程序目标”的>小节中选择要运行>的摘要选项卡>,在“部署目标”的组合框中选择您的xcode支持的版本。然后你可以在模拟器中选择并运行项目。

  2. if the project dose use features in the higher version, then you should update your Xcode in order to run the project.

    如果项目使用了更高版本中的特性,那么您应该更新Xcode以运行项目。

Hope this helps!

希望这可以帮助!

#4


1  

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.

当没有选中此设置时,我无法在模拟器中找到要启动应用程序的App图标。

#5


0  

In My Case Sole by Go->Project->Architectures->Architecture=select standard architectures(armv7,arm64)...

在我的例子中,Sole by ->项目->架构->架构=选择标准架构(armv7,arm64)…

same as

一样

Go->Target->Architectures->Architecture=select standard architectures(armv7,arm64)...

去- > - >目标架构- >建筑=选择标准体系结构(v7 arm64)…

#1


88  

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 Running

    它没有一个知道如何“运行”的构建方案。在运行/停止按钮旁边的顶部检查是否显示了配置文件名称和目标设备。如果box表示没有计划,那么点击它并创建一个新方案。如果有一个scheme,单击下拉菜单(Xcode 4.2+中的左分隔符,框中的任何地方没有),然后进入Edit scheme以确保该scheme已正确设置为运行

  • It 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

    它没有构建配置集。您应该在构建方案的运行部分看到这一点。检查有一个选择。如果列表为空,请转到最左边窗格顶部的项目图标,选择项目,进入Info部分,并创建构建配置,尽管如果可以构建项目,至少应该有一个

  • 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 Architectures and Valid Architectures on the Target before you can run it

    目标对模拟器无效,这意味着您可能需要将i386添加到目标上的体系结构和有效体系结构列表中,然后才能运行它

  • The 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

    目标对当前连接的设备无效。对于这个,检查部署目标号是否被设置到足以对设备版本的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)

    Xcode看不到连接的设备。试着拔掉插头并把它插回去。如果它仍然不能识别它,您可能还没有将它添加到Xcode(窗口->设备->选择设备->用于开发的设备)

#2


29  

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.

请确保在您的编辑方案中(单击stop按钮旁边的项目名称—>编辑方案),在Run菜单选择的Info选项卡中,您的.app被选择为可执行文件。我遇到了这个问题,在重构项目名称并重新配置构建目标之后,选择了“None”。

#3


4  

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支持。如果这是你的情况,你有两个选择来解决这个问题。

  1. 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.

    尝试在旧的部署选项中运行项目。遵循以下说明(如果项目只是设置为更高版本,而没有使用更高版本的任何特性)。这个方法应该是有效的):在xcode >中选择项目文件,选择要运行>的目标,在“iOS应用程序目标”的>小节中选择要运行>的摘要选项卡>,在“部署目标”的组合框中选择您的xcode支持的版本。然后你可以在模拟器中选择并运行项目。

  2. if the project dose use features in the higher version, then you should update your Xcode in order to run the project.

    如果项目使用了更高版本中的特性,那么您应该更新Xcode以运行项目。

Hope this helps!

希望这可以帮助!

#4


1  

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.

当没有选中此设置时,我无法在模拟器中找到要启动应用程序的App图标。

#5


0  

In My Case Sole by Go->Project->Architectures->Architecture=select standard architectures(armv7,arm64)...

在我的例子中,Sole by ->项目->架构->架构=选择标准架构(armv7,arm64)…

same as

一样

Go->Target->Architectures->Architecture=select standard architectures(armv7,arm64)...

去- > - >目标架构- >建筑=选择标准体系结构(v7 arm64)…