阅读背景:

AWS分析为iOS应用崩溃在AFNetworking

来源:互联网 

I have integrated AWS analytics(2.1.1), Facebook SDK(4.1.0) and AFNetworking(2.5.4) in one application. but app is crashing while launching itself. here is the screen shot for crash. any help would be appreciated.

我在一个应用中集成了AWS analytics(2.1.1)、Facebook SDK(4.1.0)和AFNetworking(2.5.4)。但是应用程序在启动时崩溃了。这是崩溃的画面。如有任何帮助,我们将不胜感激。

1 个解决方案

#1


1  

I have just done some inspecting in AFNetworking code.

我刚刚对网络代码做了一些检查。

When AFNetworking is loading, more specifically its class AFURLSessionManager, they do some method swizzling on NSURLSessionTask replacing the original methods with their own implementations. The reason being

当加载AFURLSessionManager时,更具体地说,当加载AFURLSessionManager类时,他们会对NSURLSessionTask执行一些方法,用自己的实现替换原始方法。原因是

A workaround for issues related to key-value observing the state of an NSURLSessionTask

处理与关键值相关的问题,观察NSURLSessionTask的状态

This is a dirty hack in AFNetworking and IMHO they should never have done something like that because it breaks the Apple API in an unexpected way. Probably your only way to fix this is either remove AFNetworking and write the communication layer by yourself (which is pretty easy) or include the AFNetworking code directly (not using a pod) and remove the swizzling part.

这是一种肮脏的黑客行为,他们不应该做这样的事情,因为它以一种意想不到的方式打破了苹果的API。解决这个问题的唯一方法可能是删除AFNetworking并自己编写通信层(这很容易),或者直接包含AFNetworking代码(不使用pod),并删除最厉害的部分。

I am not absolutely sure why the crash is happening but it is probably a use case not expected by AFNetworking developers. I would advise to put a breakpoint to af_resume and use the debugger to get information about self (e.g. po self, po [self class] etc.) and raise an issue with AFNetworking on github.

我不确定为什么会发生崩溃,但这可能是AFNetworking开发人员不希望看到的一个用例。我建议将断点设置为af_resume,并使用调试器来获取关于self的信息(例如po self, po [self class]等),并在github上添加一个AFNetworking的问题。


分享到: