我在使用Alamofire时遇到HTTP请求问题。当我尝试使用XCode调试器重现问题时,它不会崩溃,但是当我将应用程序存档并使用ios 10.0.2在我的iPad上运行.ipa文件时,我总是会崩溃。
这是运行arhived应用程序时崩溃的调用示例:
static func loginOnServerUrl(serverURL: String, user: String, password: String,
successCallback: ((JSON) -> Void)? = nil, failureCallback: ((Error) -> Void)? = nil){
let params = [
ApiParams.ACTION : "login",
ApiParams.LoginParams.USER : user,
ApiParams.LoginParams.PASSWORD : password,
]
Alamofire.request("http://\(serverURL)/AppSrv", method: .get, parameters: params).responseJSON { response in
switch response.result {
case .success(let value):
//JSON raiz
let json = JSON(value)
for (key, value) in json.acceptingSigleValueAsArray {
log("\(key) : \(value)")
}
if let successCallback = successCallback {
successCallback(json)
}
case .failure(let error):
log(error.localizedDescription)
if let failureCallback = failureCallback {
failureCallback(error)
}
}
}
}
这是我得到的崩溃日志之一:
Incident Identifier: ****
CrashReporter Key: *****
Hardware Model: iPad5,2
Process: ****
Path: ****
Identifier: ****
Version: 1.42 (1.2.3a)
Code Type: ARM-64 (Native)
Role: Foreground
Parent Process: launchd [1]
Coalition: ****
Date/Time: 2016-10-21 10:16:08.9811 +0200
Launch Time: 2016-10-21 10:16:06.2504 +0200
OS Version: iPhone OS 10.0.2 (14A456)
Report Version: 104
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Subtype: KERN_INVALID_ADDRESS at 0x000000059480bec8
Termination Signal: Segmentation fault: 11
Termination Reason: Namespace SIGNAL, Code 0xb
Terminating Process: exc handler [0]
Triggered by Thread: 0
Filtered syslog:
None found
Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0 libswiftCore.dylib 0x0000000100e19b6c 0x100c38000 + 1973100
1 myapp 0x00000001000c4d88 static ServerManager.(pingOnServerUrl(serverUrl : String, successCallback : (Int64) -> ()?, failureCallback : (Error) -> ()?) -> ()).(closure #1) (ServerManager.swift:0)
2 Alamofire 0x00000001003aca84 specialized DataRequest.(response<A where ...> (queue : DispatchQueue?, responseSerializer : A, completionHandler : (DataResponse<A.SerializedObject>) -> ()) -> Self).(closure #1).(closure #1) (ResponseSerialization.swift:0)
3 libdispatch.dylib 0x00000001889f1200 _dispatch_call_block_and_release + 24
4 libdispatch.dylib 0x00000001889f11c0 _dispatch_client_callout + 16
5 libdispatch.dylib 0x00000001889f5d6c _dispatch_main_queue_callback_4CF + 1000
6 CoreFoundation 0x0000000189b15f2c __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 12
7 CoreFoundation 0x0000000189b13b18 __CFRunLoopRun + 1660
8 CoreFoundation 0x0000000189a42048 CFRunLoopRunSpecific + 444
9 GraphicsServices 0x000000018b4c5198 GSEventRunModal + 180
10 UIKit 0x000000018fa15628 -[UIApplication _run] + 684
11 UIKit 0x000000018fa10360 UIApplicationMain + 208
12 myapp 0x00000001000bf024 main (AppDelegate.swift:16)
13 libdyld.dylib 0x0000000188a245b8 start + 4
Thread 1:
0 libsystem_kernel.dylib 0x0000000188b36a88 __workq_kernreturn + 8
1 libsystem_pthread.dylib 0x0000000188bf936c _pthread_wqthread + 1452
2 libsystem_pthread.dylib 0x0000000188bf8db4 start_wqthread + 4
Thread 2:
0 libsystem_kernel.dylib 0x0000000188b36a88 __workq_kernreturn + 8
1 libsystem_pthread.dylib 0x0000000188bf936c _pthread_wqthread + 1452
2 libsystem_pthread.dylib 0x0000000188bf8db4 start_wqthread + 4
Thread 3:
0 libsystem_pthread.dylib 0x0000000188bf8db0 start_wqthread + 0
Thread 4:
0 libsystem_pthread.dylib 0x0000000188bf8db0 start_wqthread + 0
Thread 5:
0 libsystem_kernel.dylib 0x0000000188b36a88 __workq_kernreturn + 8
1 libsystem_pthread.dylib 0x0000000188bf936c _pthread_wqthread + 1452
2 libsystem_pthread.dylib 0x0000000188bf8db4 start_wqthread + 4
Thread 6 name: com.apple.uikit.eventfetch-thread
Thread 6:
0 libsystem_kernel.dylib 0x0000000188b1816c mach_msg_trap + 8
1 libsystem_kernel.dylib 0x0000000188b17fdc mach_msg + 72
2 CoreFoundation 0x0000000189b15cec __CFRunLoopServiceMachPort + 192
3 CoreFoundation 0x0000000189b13908 __CFRunLoopRun + 1132
4 CoreFoundation 0x0000000189a42048 CFRunLoopRunSpecific + 444
5 Foundation 0x000000018a550b1c -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 304
6 Foundation 0x000000018a57160c -[NSRunLoop(NSRunLoop) runUntilDate:] + 96
7 UIKit 0x000000019038ac7c -[UIEventFetcher threadMain] + 136
8 Foundation 0x000000018a64e50c __NSThread__start__ + 1024
9 libsystem_pthread.dylib 0x0000000188bfb860 _pthread_body + 240
10 libsystem_pthread.dylib 0x0000000188bfb770 _pthread_body + 0
11 libsystem_pthread.dylib 0x0000000188bf8dbc thread_start + 4
Thread 7 name: com.apple.NSURLConnectionLoader
Thread 7:
0 libsystem_kernel.dylib 0x0000000188b1816c mach_msg_trap + 8
1 libsystem_kernel.dylib 0x0000000188b17fdc mach_msg + 72
2 CoreFoundation 0x0000000189b15cec __CFRunLoopServiceMachPort + 192
3 CoreFoundation 0x0000000189b13908 __CFRunLoopRun + 1132
4 CoreFoundation 0x0000000189a42048 CFRunLoopRunSpecific + 444
5 CFNetwork 0x000000018a22fcec +[NSURLConnection(Loader) _resourceLoadLoop:] + 336
6 Foundation 0x000000018a64e50c __NSThread__start__ + 1024
7 libsystem_pthread.dylib 0x0000000188bfb860 _pthread_body + 240
8 libsystem_pthread.dylib 0x0000000188bfb770 _pthread_body + 0
9 libsystem_pthread.dylib 0x0000000188bf8dbc thread_start + 4
Thread 0 crashed with ARM Thread State (64-bit):
x0: 0x0000000170246c30 x1: 0x0000000170246c30 x2: 0x0000000000000008 x3: 0x0000000188b7c250
x4: 0x0000000100e099a4 x5: 0x0000000100df14f8 x6: 0x0000000000000065 x7: 0x0000000170287c78
x8: 0x000000059480bea8 x9: 0x0000000ffffffff8 x10: 0x0000000000000001 x11: 0xbaddc0dedeadbead
x12: 0x0000000000000177 x13: 0x0000000000000177 x14: 0x0000000100be6a30 x15: 0x0000000000000000
x16: 0x0000000100e19b54 x17: 0xb000000000000003 x18: 0x0000000000000000 x19: 0x0000000000000000
x20: 0x0000000100e94060 x21: 0x00000001ae195ef8 x22: 0x000000017046cf40 x23: 0xb000000000000003
x24: 0x0000000000000000 x25: 0x0000000000000000 x26: 0x0000000000000004 x27: 0x0000000100be6a30
x28: 0x0000000170246c30 fp: 0x000000016fd46b60 lr: 0x00000001000c4d88
sp: 0x000000016fd46870 pc: 0x0000000100e19b6c cpsr: 0x20000000