从 Xcode 启动时 iPhone 应用程序崩溃,但从 iPhone 启动时不会
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3219532/
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
iPhone app crashes when launched from Xcode, but not from iPhone
提问by Matt Connolly
I have an app that is crashing on the iPhone, but only when it launched via Xcode.
我有一个在 iPhone 上崩溃的应用程序,但只有当它通过 Xcode 启动时。
I can see in the iPhone console log that the app receives a memory warning, and then there are some strange events like these:
我可以在 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
However, when I launch the app from the phone (not via Xcode) then it works as expected. (There is a memory warning during launch. I know it's running tight, but it recovers and doesn't crash).
但是,当我从手机(不是通过 Xcode)启动应用程序时,它会按预期工作。(启动时有内存警告。我知道它运行很紧,但它会恢复并且不会崩溃)。
This is making it particularly hard to debug other issues.
这使得调试其他问题变得特别困难。
Have I stumbled across some iOS bug?
我是否偶然发现了一些 iOS 错误?
Any ideas?
有任何想法吗?
回答by Matt Connolly
Turns out in my case that I'd forgotten that I still had the "NSZombiesEnabled" environment variable set, which was increasing the real memory usage (causing the crash) when launched from Xcode. When launched directly from Springboard, that environment variable wasn't set, and the app used lots less memory.
事实证明,在我的情况下,我忘记了我仍然设置了“NSZombiesEnabled”环境变量,这会增加从 Xcode 启动时的实际内存使用量(导致崩溃)。当直接从 Springboard 启动时,该环境变量未设置,应用程序使用的内存少得多。
It's very useful for debugging... until you run out of memory and forget it's there :)
它对调试非常有用......直到你用完内存并忘记它在那里:)
回答by inzan
This happened to me and was also due to the NSZombiesEnabled being set. In my case it was being set in a ~/.gdbinit file which I had forgotten existed. In Xcode the NSZombieEnabled checkbox was off and there was nothing set in the scheme's environment variables so it was driving me crazy trying to figure out the issue. Moral of the story is to make sure it's not set in the .gdbinit as well as in XCode.
这发生在我身上,也是由于设置了 NSZombiesEnabled。就我而言,它被设置在一个我忘记存在的 ~/.gdbinit 文件中。在 Xcode 中,NSZombieEnabled 复选框处于关闭状态,并且该方案的环境变量中没有设置任何内容,因此在试图找出问题时让我发疯。这个故事的寓意是确保它没有在 .gdbinit 和 XCode 中设置。
回答by Landon Rohatensky
I had this issue also and it was caused by having Resupported 4 installed from Cydia. After I removed it, my app launched perfectly.
我也有这个问题,它是由于从 Cydia 安装了 Resupported 4 引起的。删除它后,我的应用程序完美启动。
回答by TechZen
Usually, when you see a crash on simulator but not device or vice versa it indicates a fault with a library that is compiled for one hardware but not the other.
通常,当您看到模拟器崩溃而不是设备崩溃时,反之亦然,这表示为一个硬件而不是另一个硬件编译的库出现故障。
However, if your memory is tight, then you're probably seeing a crash caused by the subtle differences between code compiled for Intel versus code compiled for ARM. The Intel code is likely just more sensitive for some reason. The same problem will eventually occur on device if you leave it running long enough under tight memory.
但是,如果您的内存很紧,那么您可能会看到由为 Intel 编译的代码与为 ARM 编译的代码之间的细微差异导致的崩溃。出于某种原因,英特尔代码可能更敏感。如果您让它在内存紧张的情况下运行足够长的时间,最终会在设备上出现同样的问题。