xcode 在 AppDelegate 完成加载之前,我的 iPhone 应用程序在加载时崩溃
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9881084/
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
My iPhone app crashes on Load before AppDelegate finishes Loading
提问by Andrei
So I've got my awesome app, that runs perfectly on simulator or while the device is plugged in.
所以我有了我很棒的应用程序,它可以在模拟器上或在设备插入时完美运行。
And then if I create an IPA and deploy it on my device, or use TestFlight, or even submit to the App Store. The app will crash most of the time when I try launching it.
然后,如果我创建一个 IPA 并将其部署在我的设备上,或者使用 TestFlight,甚至提交到 App Store。当我尝试启动它时,该应用程序大部分时间都会崩溃。
The crash reports even not symbolized don't give me any information.
即使没有符号化的崩溃报告也不会给我任何信息。
I've used TestFlight so that it could maybe help me figure out where the app crashes, but the app Crashes before TestFlight launches.
我使用了 TestFlight 以便它可以帮助我找出应用程序崩溃的位置,但是在 TestFlight 启动之前应用程序崩溃了。
Here is some of my code (main.m):
这是我的一些代码(main.m):
#import <UIKit/UIKit.h>
#import "version3contentAppDelegate.h"
int main(int argc, char *argv[]) {
@autoreleasepool {
return UIApplicationMain(argc, argv, nil, NSStringFromClass([version3contentAppDelegate class]));
}
}
and beginning of version3contentAppDelegate.m:
和 version3contentAppDelegate.m 的开头:
#import "TestFlight.h"
#import "version3contentAppDelegate.h"
#import "RootTableViewController.h"
#import "AppsFeedTableViewController.h"
#import "AboutShmoopModalViewController.h"
@implementation version3contentAppDelegate
@synthesize window, shmoopCoreData, tabBarController;
#pragma mark -
#pragma mark Application lifecycle
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
NSLog(@"applicationDidFinishLaunching");
[TestFlight takeOff:@"3f3618576288d96d598646d060a4f26a_NzUyMjEyMDEyLTAzLTI2IDE3OjIxOjQzLjgyNzQwNg"];
...
As you can see the TestFlight code is at the beginning of the didFinishLaunching. This means that if it would crash after that, I would have a crash report on TestFlight, which I don't have.
如您所见,TestFlight 代码位于 didFinishLaunching 的开头。这意味着如果在那之后它会崩溃,我会在 TestFlight 上有一个崩溃报告,而我没有。
Would anyone have any idea why this is happening ? The project has been originally developed on an old xcode, for old iphone, currently its an xcode 3 project. But I'm programming it on XCode 4.3 with iOS 5.1 on devices.
有谁知道为什么会这样?该项目最初是在旧的 xcode 上开发的,用于旧的 iphone,目前是一个 xcode 3 项目。但我在设备上使用 iOS 5.1 在 XCode 4.3 上对其进行编程。
采纳答案by CodaFi
As per your request, here is my comment:
根据您的要求,这是我的评论:
It does get into didFinishLaunching if it shows the splash screen. I noticed you aren't using ARC, though. Could it be that you are overreleasing something? Refactor your project and see if that helps
如果它显示启动画面,它确实会进入 didFinishLaunching。不过,我注意到您没有使用 ARC。可能是你过度发布了一些东西?重构你的项目,看看是否有帮助
回答by drekka
If it crashes on your device then you will have a crash log to look at.
如果它在您的设备上崩溃,那么您将有一个崩溃日志可供查看。
Secondly, in my experience the main cause of crashes in application: didFinishLaunchingWithOptions: is due to loading resources that take too long to load.
其次,根据我的经验,应用程序崩溃的主要原因:didFinishLaunchingWithOptions: 是由于加载资源需要很长时间才能加载。
iOS has a watchdog timer which watches apps and kills them if they take too long to do certain things. Loading, unloading etc. Usually it's a couple of seconds and if they take longer than that the timer kills them, assuming they are hung.
iOS 有一个看门狗定时器,它可以监视应用程序,如果它们做某些事情的时间太长,就会杀死它们。加载、卸载等。通常是几秒钟,如果它们花费的时间超过计时器杀死它们,假设它们被挂起。
This timer is disabled for debug reasons in the simulator which is why these crashes only appear during actual device testing.
由于模拟器中的调试原因,此计时器被禁用,这就是这些崩溃仅在实际设备测试期间出现的原因。
Once you have a crash log from your local device, check the code given, if it is 0x8badf00d then it is the watch dog timer killing your app. Notice the error code 8-bad-food :-)
从本地设备获得崩溃日志后,请检查给定的代码,如果它是 0x8badf00d,那么它就是看门狗计时器杀死了您的应用程序。注意错误代码 8-bad-food :-)
Then you need to look at your code and move as much as possible onto a background thread so that the didFinishLaunchingWithOptions: method can finish asap.
然后您需要查看您的代码并尽可能多地移至后台线程,以便 didFinishLaunchingWithOptions: 方法可以尽快完成。
回答by misnomer
It could be a crash in TestFlight's launch itself - I just spent quite some time tracking down a very similar issue, where an AdHoc testing deployment was randomly, sometimes crashing on open, and it was specifically the [TestFlight takeOff:...]
line that the backtrace showed it crashing on.
这可能是 TestFlight 发布本身的崩溃 - 我只是花了很长时间来追踪一个非常相似的问题,即 AdHoc 测试部署是随机的,有时在打开时崩溃,特别[TestFlight takeOff:...]
是回溯显示它崩溃的那一行。
Get the crash logs off of the device (In all such cases where it has crashed after being at the splash screen I have had crash logs), and try using symbolicatecrash
to translate the dump - In my case, it didn't translate anything except the applicationDidFinishLaunching:withOptions
line that called into testflight.
从设备上获取崩溃日志(在所有这些情况下,它在启动屏幕后崩溃了,我有崩溃日志),并尝试使用symbolicatecrash
来转换转储 - 在我的情况下,除了applicationDidFinishLaunching:withOptions
调用 testflight 的行。
回答by Shikha Budhiraja
Its an problem with Xcode. If you are not using auto layout and size class, then delete launch xib file. Crash will be resolved.
它是 Xcode 的问题。如果您不使用自动布局和大小类,则删除启动 xib 文件。崩溃将得到解决。