我通过Crashlytics在我们的应用程序的发布版本中崩溃,我无法在我的任何设备或模拟器上复制。
我对Crashlytics的理解是,崩溃并非来自某些特定的致命错误,而是来自封闭本身的某个地方。当调用完成处理程序时,它似乎发生在第1537行,但我看不出原因。我的语法来自闭包,@escaping
的错误使用,或者解包变量,还是使用主线程来完成处理程序(因为它位于Alamofire完成处理程序中?)。
遇到崩溃的用户正在运行与我相同的iOS(11)并且我已通过她的帐户登录并且自己没有问题。
func getObjectsInBackground(completion:@escaping (_ error:AMDError?,_ objects:[Dictionary<String, Any>]?)->()){
Alamofire.request(URL(string: urlstring)!, method: .get).responseJSON { (response:DataResponse<Any>) in
switch response.result {
case .success:
let results = response.result.value as! NSArray
var objects = [Dictionary<String,Any>]()
for result in results {
let object = result as! Dictionary<String,Any>
objects.append(object)
}
DispatchQueue.main.async { //<<Line 1537
completion(nil, objects )
}
case .failure(let error):
let error = AMDError(code: "400", errorString: error.localizedDescription, info: nil)
DispatchQueue.main.async {
completion(error, nil)
}
}
}
}
这是来自crashlytics的信息
Crashed: com.apple.main-thread
0 Amondo 0x101269118 specialized MenuViewController.(loadFutureImprints() -> ()).(closure #1) (MenuViewController.swift:154)
1 Amondo 0x101278410 partial apply for MenuViewController.(loadFutureImprints() -> ()).(closure #1) + 4311073808
2 Amondo 0x10122a014 @callee_owned (@owned Error?, @owned [[String : Any]]?) -> ()AMDError? (AMDClasses.swift)
3 Amondo 0x10122a128 partial apply for specialized (AMDClasses.swift:1537)
4 Amondo 0x101205668 thunk (AMDClasses.swift)
5 libdispatch.dylib 0x180d45088 _dispatch_call_block_and_release + 24
6 libdispatch.dylib 0x180d45048 _dispatch_client_callout + 16
7 libdispatch.dylib 0x180d51b74 _dispatch_main_queue_callback_4CF$VARIANT$mp + 1016
8 CoreFoundation 0x181367f20 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 12
9 CoreFoundation 0x181365afc __CFRunLoopRun + 2012
10 CoreFoundation 0x1812862d8 CFRunLoopRunSpecific + 436
11 GraphicsServices 0x183117f84 GSEventRunModal + 100
12 UIKit 0x18a833880 UIApplicationMain + 208
13 Amondo 0x1011fe804 main (Extensions.swift:44)
14 libdyld.dylib 0x180daa56c start + 4