无法在 Xcode 4.3 中停止执行任务

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

Failure to stop executing task in Xcode 4.3

xcodeios-simulator

提问by eriknelson

I just installed Xcode 4.3 and I'm having some issues with stopping my app while running in the iOS simulator. I'm able to quit the simulator, but I cannot stop the task from running, either by hitting the stop button, or using the keybinding. In order to stop the process, I literally have to quit Xcode and restart. This obviously makes any development at all very difficult. I found this bugreport: link, which sounds very similar to the issue I'm seeing.

我刚刚安装了 Xcode 4.3,但在 iOS 模拟器中运行时停止我的应用程序时遇到了一些问题。我可以退出模拟器,但我无法通过点击停止按钮或使用键绑定来停止运行任务。为了停止这个过程,我真的不得不退出 Xcode 并重新启动。这显然使任何开发都变得非常困难。我发现了这个 bugreport: link,这听起来与我看到的问题非常相似。

Is this a known issue with 4.3, or has anyone else experienced this behavior? I haven't used Xcode for over a year now (v3), so I can't say if it was working with any other previous versions of Xcode 4.

这是 4.3 的已知问题,还是其他人遇到过这种行为?我已经一年多没有使用 Xcode (v3),所以我不能说它是否适用于任何其他以前版本的 Xcode 4。

回答by yeahdixon

Found this post helpful XCode 4.3.2, issue with running on simulator

发现这篇文章很有帮助 XCode 4.3.2,在模拟器上运行的问题

Strangely when it hangs, click on the simulator icon in the tray. Dont ask me why. This actually works

奇怪的是当它挂起时,单击托盘中的模拟器图标。不要问我为什么。这实际上有效

回答by Riccardo Moschetti

I can confirm this is still the case with Xcode 4.4 on Mountain Lion, unfortunately.

不幸的是,我可以确认,Mountain Lion 上的 Xcode 4.4 仍然是这种情况。

If I close the iOS simulator with Cmd+Q rather than leaving it open and stopping the simulation with the "Stop" button on the Xcode toolbar, the following things happen (although not systematically, but in 25% of the cases launching the same application - I believe this is related to application status but I have not understood how yet):

如果我使用 Cmd+Q 关闭 iOS 模拟器而不是让它打开并使用 Xcode 工具栏上的“停止”按钮停止模拟,则会发生以下事情(虽然不是系统性的,但在 25% 的情况下启动相同的应用程序- 我相信这与申请状态有关,但我还不明白如何):

  • the "run" button in Xcode does not open a new iOS Simulator session; the "stop" button is still clickable but gives no result;
  • the toolbar continues to say "Running on iPhone simulator" no matter how many times you click "Stop";
  • if the iOS simulator is launched manually, it is not linked to the Xcode session;
  • not only does one have to re-start XCode: the restart has to be forcedas the simple Xcode "Quit" command will not work.
  • Xcode 中的“运行”按钮不会打开新的 iOS 模拟器会话;“停止”按钮仍然可以点击但没有结果;
  • 无论您单击“停止”多少次,工具栏都会继续显示“在 iPhone 模拟器上运行”;
  • 如果 iOS 模拟器是手动启动的,它不会链接到 Xcode 会话;
  • 不仅必须重新启动 XCode:必须强制重新启动,因为简单的 Xcode“退出”命令将不起作用。

回答by Mick MacCallum

I've noticed this a lot since updating. The cure seems to be to just try to remember to stop the application from within Xcode while the simulator is still running the app. It seems like when you kill the simulator out from under Xcode your simulator process hangs and doesn't pass the termination message on to Xcode like it is supposed to.

自从更新以来,我已经注意到了很多。解决方法似乎只是尝试记住在模拟器仍在运行应用程序时从 Xcode 中停止应用程序。似乎当您从 Xcode 下杀死模拟器时,您的模拟器进程会挂起,并且不会像预期的那样将终止消息传递给 Xcode。

回答by Seth Kingsley

Not really a solution, but I just overrode the “Quit iOS Simulator” keyboard shortcut in System Preferences to something I'm unlikely to type impulsively, like ??Q.

不是真正的解决方案,但我只是将系统偏好设置中的“退出 iOS 模拟器”键盘快捷键改写为我不太可能冲动输入的内容,例如 ??Q。

回答by basvk

I've been having a similar problem which can be resolved by restarting Xcode, but it's quite annoying. I've managed to get a workaround for this 'problem'.

我遇到了类似的问题,可以通过重新启动 Xcode 来解决,但这很烦人。我已经设法解决了这个“问题”。

  1. Go to ~/Applications/and open the context menu for Xcode.app and select Show Package Contents

  2. Navigate to /Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Applications/

  3. Copy iOS Simulator.appand paste it to (for instance) your Desktop

  4. Next start your OSX system preferences panel and navigate to Keyboard

  5. Select the second tab Keyboard Shortcuts

  6. Select Application Shortcutson the left side

  7. Press the small +sign on the right side

  8. A small dialog appears.
    Select the copied iOS Simulator.appin the first selectbox > Other...

  9. As Menu Titlefill in Home

  10. And for the menu shortcut 'type' COMMAND + Q

  11. Now hit Addand close your system preferences

  12. Delete iOS Simulator.appfrom your Desktop.

  1. 转到~/Applications/并打开 Xcode.app 的上下文菜单并选择Show Package Contents

  2. 导航 /Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Applications/

  3. iOS Simulator.app其复制并粘贴到(例如)您的桌面

  4. 接下来启动您的 OSX 系统首选项面板并导航到 Keyboard

  5. 选择第二个标签 Keyboard Shortcuts

  6. Application Shortcuts在左侧选择

  7. +右边的小标志

  8. 出现一个小对话框。在第一个
    选择框中选择复制iOS Simulator.app>Other...

  9. 作为Menu Title填写Home

  10. 而对于菜单快捷方式“类型” COMMAND + Q

  11. 现在点击Add并关闭您的系统首选项

  12. iOS Simulator.app从桌面删除。

If you now start the simulator through Xcode and (accidentally) want to quit the simulator while it's running and attached to Xcode > you can't.

如果您现在通过 Xcode 启动模拟器,并且(不小心)想在模拟器运行并连接到 Xcode 时退出模拟器 > 您不能。

I know it doesn't fix the problem itself, but for those pro-users who use keyboard shortcuts for everything this might help a bit.

我知道它本身并不能解决问题,但是对于那些将键盘快捷键用于所有事情的专业用户来说,这可能会有所帮助。