0

I submitted my app to the AppStore and Apple said it is crashing on launch. I fully tested this in all the simulators and on a physical device and I was unable to replicate this, everything works. But whatever device/process Apple is using, they say it is crashing on launch.

I got the crash log and opened it in XCode and was able to see where is seems to be crashing, but everything else in it makes no sense to me. I can't explain it or say why. Just by looking at it, seems to crash when it is trying to get ABAutorization and get the ABContacts, but I can't replicate this issue, so I'm confused. Hoping someone can help:

 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

This is my getAB() function just incase:

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

    }
Lavvo
  • 1,024
  • 3
  • 16
  • 35
  • Seems like this issue : https://stackoverflow.com/questions/46765852/crash-on-ios-tccaccessrequest-block-invoke-2-8 – Farhan Apr 15 '18 at 09:05

1 Answers1

0

try to use optional expression:

addressBook = ABAddressBookCreateWithOptions(nil, &error)?.takeRetainedValue()
dimpiax
  • 12,093
  • 5
  • 62
  • 45