Swift Crash libobjc.A.dylib objc_msg发送 [英] Swift Crash libobjc.A.dylib objc_msgSend

查看:317
本文介绍了Swift Crash libobjc.A.dylib objc_msg发送的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用crashlytics来获取AppStore中我的应用程序的崩溃。有些用户崩溃了,我似乎无法在自己的机器上进行复制(没有几个朋友通过TestFlight测试了我的应用程序)。这是来自Fabric的日志:

I use crashlytics to get the crashes of my app that is in the AppStore. Some users are getting a crash that I cannot seem to repro on my machine (neither the few friends that tested my app through TestFlight). This is the logs from Fabric:

Thread : Crashed: com.apple.main-thread
0  libobjc.A.dylib                0x181d09bdc objc_msgSend + 28
1  Foundation                     0x18304be20 __NSThreadPerformPerform + 340
2  CoreFoundation                 0x182640efc __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 24
3  CoreFoundation                 0x182640990 __CFRunLoopDoSources0 + 540
4  CoreFoundation                 0x18263e690 __CFRunLoopRun + 724
5  CoreFoundation                 0x18256d680 CFRunLoopRunSpecific + 384
6  GraphicsServices               0x183a7c088 GSEventRunModal + 180
7  UIKit                          0x1873e4d90 UIApplicationMain + 204
8  <App Name>                     0x1000b2f0c main (AppDelegate.swift:14)
9  libdispatch.dylib              0x18210e8b8 (Missing)

我似乎无法理解这意味着什么,并搜索了其他问题以寻求帮助,但似乎找不到答案。我还迅速联系了Crashlytics小组,他们告诉了我以下内容:

I can't seem to understand what this means and searched other questions for help but can't seem to find an answer. I also quickly contacted the Crashlytics team, and they told me the following:


听起来这起事故的源头是某种原因内存崩溃。这会导致Crashlytics在完成写入之前关闭,从而在崩溃报告中显示该问题。

It sounds like the source of this crash is some sort of out of memory crash. This causing Crashlytics to close before it finishes writing, resulting in this in your crash report.

任何一种调试此错误的好方法查明崩溃的根源?感谢帮助!

Any nice ways to debug this in order to pinpoint the source of the crash? Appreciate the help!

编辑:
在崩溃报告中添加了崩溃解析中线程的屏幕截图,以防有人想要从那里获取一些信息:

Added screenshot of Threads in the crash report from crashlytics in case someone wants some info from there:

Thread : com.apple.NSURLConnectionLoader
0  libsystem_kernel.dylib         0x1823354bc mach_msg_trap + 8
1  libsystem_kernel.dylib         0x182335338 mach_msg + 72
2  CoreFoundation                 0x182764ac0 __CFRunLoopServiceMachPort + 196
3  CoreFoundation                 0x1827627c4 __CFRunLoopRun + 1032
4  CoreFoundation                 0x182691680 CFRunLoopRunSpecific + 384
5  CFNetwork                      0x182e01434 +[NSURLConnection(Loader) _resourceLoadLoop:] + 412
6  Foundation                     0x18316fc40 __NSThread__start__ + 1000
7  libsystem_pthread.dylib        0x182417b28 _pthread_body + 156
8  libsystem_pthread.dylib        0x182417a8c _pthread_body + 154
9  libsystem_pthread.dylib        0x182415028 thread_start + 4

Thread : AVAudioSession Notify Thread
0  libsystem_kernel.dylib         0x1823354bc mach_msg_trap + 8
1  libsystem_kernel.dylib         0x182335338 mach_msg + 72
2  CoreFoundation                 0x182764ac0 __CFRunLoopServiceMachPort + 196
3  CoreFoundation                 0x1827627c4 __CFRunLoopRun + 1032
4  CoreFoundation                 0x182691680 CFRunLoopRunSpecific + 384
5  libAVFAudio.dylib              0x188959834 GenericRunLoopThread::Entry(void*) + 164
6  libAVFAudio.dylib              0x18892e3a8 CAPThread::Entry(CAPThread*) + 84
7  libsystem_pthread.dylib        0x182417b28 _pthread_body + 156
8  libsystem_pthread.dylib        0x182417a8c _pthread_body + 154
9  libsystem_pthread.dylib        0x182415028 thread_start + 4

编辑2:
我正在使用所有Swift代码,而我向选择器转发消息的方式如下:

EDIT 2: I am using all Swift code, and the way I am forwarding a messages to Selectors is the following:

NSTimer.scheduledTimerWithTimeInterval(0.02, target: self, selector: Selector("updateProgressCircle"), userInfo: nil, repeats: true)

func updateProgressCircle() {
   // Do something
}

问题是我无法复制任何崩溃从本地。只有用户面对。我以类似的方式调用选择器。

Problem is that I can't repro any crash from this locally. Only users are facing that. I call selectors in a similar fashion.

推荐答案

发生 objc_msgSend 崩溃当您尝试将消息转发到选择器时(使用良好的旧Objective-C转发消息)。这可以通过目标动作,通知,协议声明,计时器,执行选择器或涉及传递函数选择器语法的任何其他函数来产生:即: doSomethingWithThis:

An objc_msgSend crash happens when you try to forward a message to a selector (using good old Objective-C forward messaging). This can be produced by target-action, notifications, protocol declarations, timers, perform selectors or any other function that involves passing in a function's selector syntax: i.e: "doSomethingWithThis:".

我从崩溃日志中看到,您的应用程序(至少是AppDelegate)中包含快速组件。与Obj-C组件不同,Swift组件与现成的Obj-C转发消息系统不兼容。

I can see from your crash logs that you have swift components in your app (at least the AppDelegate). Swift components, unlike Obj-C components, aren't compatible with the Obj-C forward messaging system out of the box.

我的直觉是您的敏捷代码中符合协议的对象,被添加为目标/通知观察者,或以某种方式期望正向消息传递调用其功能之一。我建议您上课,看看是否是这种情况。一旦找到罪魁祸首,您就可以通过将@objc附加到期望消息的函数中来轻松修复此错误。

My gut feeling is that you have a swift object in your code that conforms to a protocol, is added as a target/notification observer or is somehow expecting one of its functions to be called by forward messaging. I suggest you go through your classes and see if this is the case. Once you find the culprit you can easily fix this error by appending @objc to the function expecting the message.

ie:
(如果您的函数很快)该类将被调用(并注册为通知):

i.e: if your function, in a swift class is called (and is, say, registered for a notification):

func yourFunction() {
   //your code
}

调用它:

@objc func yourFunction() {
  //your code
}

这是一个远景,但我希望这会有所帮助!

It's a long shot but I hope this helps!

这篇关于Swift Crash libobjc.A.dylib objc_msg发送的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆