从Xcode启动iPhone应用程序崩溃,但从iPhone启动不会。

4

我有一个应用程序,在iPhone上启动时会崩溃,但只有在通过Xcode启动时才会出现。

我可以在iPhone控制台日志中看到应用程序收到内存警告,然后会出现一些奇怪的事件,例如:

Sun Jul 11 00:03:43 Matts-iPhone com.apple.launchd[1] (UIKitApplication:com.mycom.myapp[0x3f60][5591]) <Notice>: (UIKitApplication:com.mycom.myapp[0x3f60]) Bug: launchd_core_logic.c:3270 (24132):0
Sun Jul 11 00:03:43 Matts-iPhone com.apple.debugserver-48[5590] <Warning>: 1 [15d6/1403]: error: ::read ( 6, 0x3809f4, 1024 ) => -1 err = Bad file descriptor (0x00000009)
Sun Jul 11 00:03:43 Matts-iPhone com.apple.launchd[1] (UIKitApplication:com.mycom.myapp[0x3f60][5591]) <Notice>: (UIKitApplication:com.mycom.myapp[0x3f60]) Bug: launchd_core_logic.c:2688 (24132):10
Sun Jul 11 00:03:43 Matts-iPhone com.apple.launchd[1] (UIKitApplication:com.mycom.myapp[0x3f60][5591]) <Notice>: (UIKitApplication:com.mycom.myapp[0x3f60]) Working around 5020256. Assuming the job crashed.
Sun Jul 11 00:03:43 Matts-iPhone com.apple.launchd[1] (UIKitApplication:com.mycom.myapp[0x3f60][5591]) <Warning>: (UIKitApplication:com.mycom.myapp[0x3f60]) Job appears to have crashed: Segmentation fault
Sun Jul 11 00:03:43 Matts-iPhone SpringBoard[40] <Warning>: Application 'Phone' exited abnormally with signal 9: Killed
Sun Jul 11 00:03:45 Matts-iPhone SpringBoard[40] <Warning>: Application 'myapp' exited abnormally with signal 11: Segmentation fault

然而,当我从手机上启动应用程序时(而不是通过Xcode),它按预期工作。(在启动期间会出现内存警告。我知道它运行紧张,但它会恢复并且不会崩溃)。

这使得调试其他问题特别困难。

我是否遇到了某个iOS bug?

有什么想法吗?

4个回答

7

事实证明,在我的情况下,我忘记了我仍然设置了 "NSZombiesEnabled" 环境变量,这会在从 Xcode 启动时增加实际内存使用量(导致崩溃)。当直接从 Springboard 启动时,该环境变量未设置,应用程序使用的内存要少得多。

这对于调试非常有用... 直到你耗尽了内存并忘记它的存在:)


2

我也遇到了同样的问题,原因是NSZombiesEnabled被设置了。在我这个例子里,它被设置在一个我已经忘记存在的~/.gdbinit文件中。在Xcode中,NSZombieEnabled复选框被关闭,并且在scheme的环境变量中也没有设置,所以我一直在努力找出这个问题。故事的寓意是要确保不仅在XCode中,而且在.gdbinit文件中也未被设置。


2

我也遇到了这个问题,原因是在Cydia中安装了Resupported 4。卸载后,我的应用程序完美启动。


我的问题是来自Cydia的uididfaker和locationholic,卸载它们后,Xcode在我的iPhone上正常运行。 - ozba

0
通常,如果您在模拟器上看到崩溃,而在设备上没有或反之亦然,则表明编译为一种硬件而非另一种的库存在故障。
但是,如果您的内存很紧张,那么您可能会看到由于为Intel编译的代码与为ARM编译的代码之间的微妙差异而导致的崩溃。由于某种原因,Intel代码可能更加敏感。如果您在紧缩内存的情况下让设备长时间运行,同样的问题最终也会发生在设备上。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接