ios 加载时应用程序崩溃,main.m 中出错
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7855627/
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
App crashes while loading with error in main.m
提问by cory ginsberg
I'm trying to recover an app that I accidentally deleted and managed to do it through the organizer, however, now when I try to run it on the simulator or iphone, it crashes with an error popping up in the main.m file:
我正在尝试恢复我不小心删除并设法通过组织者完成的应用程序,但是,现在当我尝试在模拟器或 iPhone 上运行它时,它崩溃并在 main.m 文件中弹出错误:
int main(int argc, char *argv[])
{
@autoreleasepool {
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
}
}
The error occurs in the "return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));" section of the file with the SIGABRT error. I am using Xcode 4.2 with ARC on. I am testing it on ios 4.3 and ios 5.0. The app was working before and in fact, is on the app store right now. Anything would help
错误发生在“return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));” 具有 SIGABRT 错误的文件部分。我正在使用带有 ARC 的 Xcode 4.2。我正在 ios 4.3 和 ios 5.0 上测试它。该应用程序之前可以运行,实际上现在在应用程序商店中。任何事情都会有所帮助
采纳答案by dgund
If you look in the debugger it will probably tell you what caused the error. This has happened to me before, due to insufficient memory (too many items on screen at once). Either way, look at the target debugger for what caused the error.
如果您查看调试器,它可能会告诉您导致错误的原因。由于内存不足(一次屏幕上的项目太多),我以前也发生过这种情况。无论哪种方式,请查看目标调试器以了解导致错误的原因。
回答by tomDev
Usually when I get similar errors is because there is a broken link on the Interface Builder. Maybe you've changed the name of an IBOutlet and forgot to connect it again.
通常,当我遇到类似错误时,是因为 Interface Builder 上的链接已损坏。也许您已经更改了 IBOutlet 的名称并忘记再次连接它。
回答by DanWebster
If you are using Storyboards, make sure you haven't hooked up duplicate referencing outlets or reference outlets that aren't there anymore in your code. In other words, if you dragged from a button on your view controller to your code and then the property or method has changed at all, you can get this error.
如果您使用的是故事板,请确保您没有连接重复的引用出口或代码中不再存在的引用出口。换句话说,如果您从视图控制器上的按钮拖动到您的代码,然后属性或方法发生了根本变化,您可能会收到此错误。
回答by Pattie Pants
happened to me, looked in the debugger and found it mentioned a name I given to an action, but deleted it after I created it both viewController .h and .m so for some reason that old action created with a different name, still lingered somewhere... so I copied my code and pasted it on a new prog. Of course, it was a very small one view app so it was easy...
发生在我身上,查看调试器,发现它提到了我给一个动作的名称,但是在我创建了 viewController .h 和 .m 之后删除了它,所以出于某种原因,使用不同名称创建的旧动作仍然在某处徘徊...所以我复制了我的代码并将其粘贴到一个新的编上。当然,这是一个非常小的单视图应用程序,所以很容易......
回答by user1427192
It happened to me and all I did was changed the name of my image view and than changed it back later. But, I forgot to disconnect the other name after I deleted it. However, once I disconnected it from interface builder it worked.
它发生在我身上,我所做的只是更改了图像视图的名称,然后再将其改回来。但是,我删除它后忘记断开另一个名称。但是,一旦我将它与界面构建器断开连接,它就可以工作了。
回答by Flavien Volken
Crashed with LLDP debugger I changed to GDB and then it worked.
使用 LLDP 调试器崩溃,我改为 GDB,然后它工作了。
I got stuck with this problem too but not all the time only 1/2 launch. Absolutely no error in the console no nothing, just a signal SIGARBT. My AppDelegate did not even went to didFinishLaunchingWithOptions. Changing the debugger back to GDB (Edit Scheme… > (Info tab) Debugger > LLDB) solved the problem.
我也遇到了这个问题,但并非总是只有 1/2 启动。控制台中绝对没有错误,什么也没有,只是一个信号 SIGARBT。我的 AppDelegate 甚至没有去 didFinishLaunchingWithOptions。将调试器改回 GDB(编辑方案…>(信息选项卡)调试器>LLDB)解决了这个问题。
回答by logancautrell
I've seen this happen before if the following build settings are not there. OTHER_LDFLAGS = -ObjC -all_load
如果以下构建设置不存在,我之前已经看到这种情况发生。OTHER_LDFLAGS = -ObjC -all_load
This is under Linking in the target.
这是在目标中的链接下。
回答by FeifanZ
Not sure what the error message is—that would be helpful. But are you importing AppDelegate.h?
不确定错误消息是什么 - 这会有所帮助。但是你是在导入 AppDelegate.h 吗?
回答by Maverick10
To fix it, click on mainstoryboard i.e. Interface Builder, select the File Inspector tab, and uncheck Use autolayout. Alternatively, you can target iOS 6.0+-only devices and change the minimum target, if you absolutely must have autolayout. This problem occurs due to mismatch in versions of xcode and source of learning programs from.
要修复它,请单击 mainstoryboard ie Interface Builder,选择 File Inspector 选项卡,然后取消选中 Use autolayout。或者,如果您绝对必须使用自动布局,您可以针对仅 iOS 6.0+ 的设备并更改最小目标。出现此问题是由于 xcode 版本和学习程序来源不匹配。