我将我的应用程序提交给AppStore,Apple称它在发布时崩溃了。我在所有模拟器和物理设备上对此进行了全面测试,但我无法复制它,一切正常。但无论Apple使用何种设备/流程,他们都说它在发布时会崩溃。
我收到了崩溃日志并在XCode中打开它,并且能够看到哪里似乎崩溃了,但其中的其他一切对我来说都没有意义。我无法解释或说出原因。只是通过观察它,似乎在试图获得ABAutorization并获得ABContacts时崩溃,但我无法复制这个问题,所以我很困惑。希望有人可以提供帮助:
Thread 4 name: Dispatch queue: com.apple.root.default-qos
Thread 4 Crashed:
0 libswiftCore.dylib 0x000000010032e4e8 0x1001b4000 + 1549544
1 libswiftCore.dylib 0x000000010030abf4 0x1001b4000 + 1403892
2 Phonelist 0x00000001001112f8 Phonelist.AddressBookEngine.getAllContacts (Phonelist.AddressBookEngine.Type)(Swift.AnyObject) -> () (AddressBookEngine.swift:247)
3 Phonelist 0x00000001001161b0 Phonelist.AddressBookEngine.(getABAuth (Phonelist.AddressBookEngine.Type) -> (Swift.String) -> ()).(closure #1) (AddressBookEngine.swift:189)
4 AddressBook 0x0000000185d2b284 __37-[ABTCC accessRequestWithCompletion:]_block_invoke + 44
5 TCC 0x0000000192ab56ec __TCCAccessRequest_block_invoke56 + 420
6 TCC 0x0000000192ab7524 __tccd_send_block_invoke + 40
7 libxpc.dylib 0x00000001980186b4 _xpc_connection_reply_callout + 44
8 libxpc.dylib 0x0000000198018644 _xpc_connection_call_reply + 36
9 libdispatch.dylib 0x0000000197e15368 _dispatch_client_callout + 12
10 libdispatch.dylib 0x0000000197e21408 _dispatch_root_queue_drain + 1148
11 libdispatch.dylib 0x0000000197e22758 _dispatch_worker_thread3 + 104
12 libsystem_pthread.dylib 0x0000000197ff12e0 _pthread_wqthread + 812
13 libsystem_pthread.dylib 0x0000000197ff0fa4 start_wqthread + 0
这是我的getAB()函数,只是包含:
static func getABAuth(action: String){
var addressBook: ABAddressBookRef?
var error: Unmanaged<CFError>? = nil
if ABAddressBookGetAuthorizationStatus() == ABAuthorizationStatus.Authorized || ABAddressBookGetAuthorizationStatus() == ABAuthorizationStatus.NotDetermined{
Scripts.log("Access Recognized to address book")
addressBook = ABAddressBookCreateWithOptions(nil, &error).takeRetainedValue()
if addressBook == nil{
println(error)
return
}
ABAddressBookRequestAccessWithCompletion(addressBook){
(granted:Bool, err:CFError!) in
if granted {
//addressBook = addressBook
Scripts.log("Access Granted to address book")
if (action == "add"){
self.addContact(addressBook!)
}
if (action == "get"){
self.getAllContacts(addressBook!)
}
}
else {
println(err)
}
}
}
if ABAddressBookGetAuthorizationStatus() == ABAuthorizationStatus.Denied{
Scripts.log("Access denied to address book")
}
if ABAddressBookGetAuthorizationStatus() == ABAuthorizationStatus.Restricted{
Scripts.log("Access restricted to address book")
}
//return false
}
答案 0 :(得分:0)
尝试使用可选表达式:
addressBook = ABAddressBookCreateWithOptions(nil, &error)?.takeRetainedValue()