xcode iOS 应用程序每隔一次启动就会崩溃,找不到错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16113848/
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
iOS app crashing every other launch, can't find error
提问by Beau Nouvelle
First time I launch the app, everything seems to run fine. I'll hit the stop button, do some work and when I go to launch it again, it seems to crash before it can even load anything. Press stop, hit Run again, and it works fine. Until I repeat the process.
我第一次启动该应用程序时,一切似乎都运行良好。我会按下停止按钮,做一些工作,当我再次启动它时,它似乎在加载任何东西之前就崩溃了。按停止,再次点击运行,它工作正常。直到我重复这个过程。
This is where xcode is highlighting the error with "Thread 1:signal SIGABRT". Obviously nothing useful here.
这是 xcode 用“Thread 1:signal SIGABRT”突出显示错误的地方。显然这里没有任何用处。
int main(int argc, char *argv[])
{
@autoreleasepool {
return UIApplicationMain(argc, argv, nil, NSStringFromClass([PokerAppDelegate class]));
}
}
The debug console shows nothing besides (lldb) (So I suppose its stopping, not crashing at this point)
So, when I perform a BT
this is what I get:
调试控制台除了 (lldb) 之外什么也没有显示(所以我想它正在停止,此时不会崩溃)所以,当我执行 aBT
这就是我得到的结果:
(lldb) bt
* thread #1: tid = 0x1c03, 0x9a258a6a libsystem_kernel.dylib`__pthread_kill + 10, stop reason = signal SIGABRT
frame #0: 0x9a258a6a libsystem_kernel.dylib`__pthread_kill + 10
frame #1: 0x99ea1b2f libsystem_c.dylib`pthread_kill + 101
frame #2: 0x04a7057b libsystem_sim_c.dylib`abort + 140
frame #3: 0x01dc0b4e GraphicsServices`GSRegisterPurpleNamedPort + 348
frame #4: 0x01dc069f GraphicsServices`_GSEventInitialize + 123
frame #5: 0x01dc0c1f GraphicsServices`GSEventInitialize + 36
frame #6: 0x000163f9 UIKit`UIApplicationMain + 600
frame #7: 0x00001d0d Guitar Chord Poker HD`main(argc=1, argv=0xbffff32c) + 141 at main.m:16
frame #8: 0x00001c35 Guitar Chord Poker HD`start + 53
(lldb)
Here's what I have done so far:
这是我到目前为止所做的:
- Performed a 'Clean'
- I've reset the simulators and reset my computer
- I've commented out all the code in the view controller, still crashes
- I've commented out all the code in the app delegate, still crashes
- BUT....I've run the app on a device outside of Xcode, and it seems to work perfectly fine.
- (EDIT) I've deleted/reinstalled xcode, and all content(Simulators, Docs) from the various cache folders (This stops xcode from automatically reinstalling the old ones after a new download). Still can't find where command line tools is kept though. Still crashes.
- 执行“清洁”
- 我已经重置了模拟器并重置了我的电脑
- 我已经注释掉了视图控制器中的所有代码,仍然崩溃
- 我已经注释掉了应用程序委托中的所有代码,仍然崩溃
- 但是......我已经在 Xcode 之外的设备上运行了该应用程序,它似乎工作得很好。
- (编辑)我已经删除/重新安装了 xcode,以及各种缓存文件夹中的所有内容(模拟器、文档)(这会阻止 xcode 在新下载后自动重新安装旧的)。尽管如此,仍然找不到命令行工具的保存位置。还是会崩溃。
Despite all this, apps still crash every second/other launch.
尽管如此,应用程序仍然会在每秒/其他启动时崩溃。
Thing is I had no issues until the most recent Xcode update. Could it be an Xcode bug?
事情是在最近的 Xcode 更新之前我没有问题。会不会是 Xcode 的错误?
(EDIT) I am also running the latest developer releases of OSX. Could that be interfering?
(编辑)我也在运行 OSX 的最新开发者版本。那会不会有干扰?
采纳答案by nevan king
Seems to be a combination of OS X 10.8.4 and LLDB. As kenster says, switching to GDB makes the problem go away.
似乎是OS X 10.8.4 和 LLDB的组合。正如 kenster 所说,切换到 GDB 会使问题消失。
Edit:
It's caused by a race condition in the debug server (I hear).
编辑:
这是由调试服务器中的竞争条件引起的(我听说)。
Here's a fix if you want to keep using LLDB: Instead of clicking Run while the app is already running in the simulator, kill it in Xcode (?-.), say "I love Xcode" 5 times and Run it again (?-R). It won't crash, I tested it.
如果你想继续使用 LLDB,这里有一个解决方法:当应用程序已经在模拟器中运行时,不要点击运行,而是在 Xcode 中杀死它 (?-.),说“我爱 Xcode”5 次,然后再次运行它 (?- R)。它不会崩溃,我测试了它。
Fixedin Xcode 4.6.3.
已在Xcode 4.6.3 中修复。
回答by kenster
I was having this issue as well. Take a look at this post. Xcode 4.6.2 app crashes on every second run
我也遇到了这个问题。看看这个帖子。Xcode 4.6.2 应用程序每运行一次就会崩溃
Basically change your debugger from LLDB to GDB. I can't believe this was due to LLDB being buggy.
基本上将您的调试器从 LLDB 更改为 GDB。我不敢相信这是因为 LLDB 有问题。
回答by Mekugi
Switching to GDB or rebooting device/host does not solve the issue in my environment.
切换到 GDB 或重新启动设备/主机并不能解决我的环境中的问题。
However, modifying the Run target in the associated XCode scheme to no longer launch automatically but instead to "Wait for HelloWorld.app to launch"did.
但是,将关联的 XCode 方案中的 Run 目标修改为不再自动启动,而是“等待HelloWorld.app 启动”。
Only drawback is that this implies to manually start the application on the device. The debugger will then get connected.
唯一的缺点是这意味着在设备上手动启动应用程序。然后调试器将被连接。