MacOS 应用程序无法在 Xcode 模拟器上运行

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8244953/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 04:10:57  来源:igfitidea点击:

MacOS app does not run on the Xcode simulator

xcodemacos

提问by Bas

I've installed Xcode 4.2.1on Mac OS X Lion.

我已经在 Mac OS X Lion 上安装了Xcode 4.2.1

When I create a new (Mac OS X Cocoa) project and I click "Run", Xcode says build succeeded, but doesn't run the project. No errors, but no application either.

当我创建一个新的 (Mac OS X Cocoa) 项目并单击“运行”时,Xcode 说构建成功,但没有运行该项目。没有错误,但也没有应用程序。

When I do exactly the same thing on another Mac (but with OS X Snow Leopard and Xcode 4.0.1 installed), the created app starts bouncing in the dock and shows an empty window, like I would expect.

当我在另一台 Mac 上做完全相同的事情时(但安装了 OS X Snow Leopard 和 Xcode 4.0.1),创建的应用程序开始在 Dock 中弹跳并显示一个空窗口,就像我期望的那样。

When I look in the Console, there seems to be nothing strange going on. I tried reinstalling Xcode, deleting everything related to Xcode, but still no luck.

当我查看控制台时,似乎没有什么奇怪的事情发生。我尝试重新安装 Xcode,删除与 Xcode 相关的所有内容,但仍然没有运气。

Anyone got an idea what could be the problem?

任何人都知道可能是什么问题?

(I tried running an existing project which used to work, but that didn't show anything either)

(我尝试运行一个曾经可以工作的现有项目,但也没有显示任何内容)

Thanks.

谢谢。

回答by Chad Marmon

I had a similar problem with Xcode 4.5.2.

我在 Xcode 4.5.2 上遇到了类似的问题。

To fix it I had to go to the menu Product > Edit Scheme... > Select "Run " (in the sidebar) > Info (tab). In here is a drop down box labeled Executable, select it and choose your app that you wish to launch when the Run button is clicked.

要修复它,我必须转到菜单 Product > Edit Scheme... > 选择“Run”(在侧边栏中)> Info(选项卡)。这里有一个标有 Executable 的下拉框,选择它并选择您希望在单击 Run 按钮时启动的应用程序。

回答by cardmagik

I messed up my settings and had this same issue - builds the app but doesn't launch (either in the simulator or the device).

我搞砸了我的设置并遇到了同样的问题 - 构建了应用程序但没有启动(在模拟器或设备中)。

The answer Product > Edit Scheme got me half way there - then choose Run {your app} on the left. There is a launch Automatically radio button to check: enter image description here

答案 Product > Edit Scheme 让我成功了 - 然后选择左侧的 Run {your app}。有一个自动启动单选按钮来检查: 在此处输入图片说明

回答by Josiah

I had the same issue in late 2017 with Xcode 9.2.Uncheck 'Debug Executable'

我在 2017 年底使用 Xcode 9.2 遇到了同样的问题。取消选中“调试可执行文件”

I had to uncheck'Debug Executable' and then my app was able to both run and stop.

我必须取消选中“调试可执行文件”,然后我的应用程序才能运行和停止。

You can open the settings by clicking Product -> Scheme -> Edit Scheme...

您可以通过单击 Product -> Scheme -> Edit Scheme... 打开设置

回答by Old McStopher

Simple

简单的

Select the desired active scheme and device/simulator from the toolbar (next to the "play" and "stop" buttons).

从工具栏(“播放”和“停止”按钮旁边)选择所需的活动方案和设备/模拟器。

The scheme selection should look something like below where the name is that of the appropriate target.

方案选择应如下所示,其中名称是适当目标的名称。

Set proper scheme and device/simulator.

设置适当的方案和设备/模拟器。

回答by Will Von Ullrich

I know this is a well accepted answered question, however for those who are building / running on a physical device

我知道这是一个很好的回答问题,但是对于那些在物理设备上构建/运行的人

SOLUTION:Hard-restart the device, then clean the project in Xcode ?+?+K.

解决方案:硬重启设备,然后在 Xcode ?+?+K 中清理项目。

I think the bundle gets confused causing Xcode to "think" it already ran the project, therefore showing "Finished" instead of launching whichever application you selected to run.

我认为捆绑包变得混乱,导致 Xcode“认为”它已经运行了项目,因此显示“已完成”而不是启动您选择运行的任何应用程序。

回答by Warren Burton

Check if your project has entitlements enabled. Sandbox or iCloud or both.

检查您的项目是否启用了权利。沙盒或 iCloud 或两者兼而有之。

If you have that enabled and you dont have an appropriate cert from the Dev portal your app will build but not launch.

如果您启用了该功能并且您没有来自开发门户的适当证书,您的应用程序将构建但不会启动。

Switch the entitlements off if you are not actively developing functionality around them.

如果您没有积极开发围绕它们的功能,请关闭这些权利。

The Console app will show this up as a permissions failure. But oddly not the Xcode debug console.

控制台应用程序会将其显示为权限失败。但奇怪的是不是 Xcode 调试控制台。

回答by Vladislav

I had similar problems. I found that the problem was in ~/.gdbinit file. And a second time - at the window initialization function loadWithNibName/initWithWindow (wrong name nib file or frame properties). Also check the file Info.plist in your project (parameters "Main nib file base name" and "Principal class").

我有类似的问题。我发现问题出在 ~/.gdbinit 文件中。第二次 - 在窗口初始化函数 loadWithNibName/initWithWindow (错误的名称 nib 文件或框架属性)。还要检查项目中的文件 Info.plist(参数“Main nib 文件基名”和“主体类”)。

回答by Jerry Chong

Xcode 10.2

Xcode 10.2

Steps:

脚步:

  1. Product -> Scheme -> Edit Scheme
  2. Run
  3. Info
  4. Executable -> Yourproject.app
  5. Run whole project again
  1. 产品 -> 方案 -> 编辑方案
  2. 信息
  3. 可执行文件 ->你的项目.app
  4. 再次运行整个项目

Screenshot: enter image description here

截屏: 在此处输入图片说明

回答by kmiklas

Do you have the correct project selected to run?

您是否选择了要运行的正确项目?

Click on the project name next to the stop button (top left). Are there multiple projects listed? Do you have the correct one selected?

单击停止按钮(左上角)旁边的项目名称。是否列出了多个项目?你选对了吗?

回答by Rob Keniger

Try removing the dev tools by running

尝试通过运行删除开发工具

sudo Developer/Library/uninstall-devtools --mode=all

in Terminal. This will properly remove all components of the dev tools, including the command-line components.

在终端。这将正确删除开发工具的所有组件,包括命令行组件。

You can then try a re-install.

然后您可以尝试重新安装。