1

I am updating one of my apps to Swift 3 and i am using the APAddressBook Library (https://github.com/Alterplay/APAddressBook) as always. Here is a Swift example from APAddressBook but this fails, too

self.addressBook.loadContacts({ (contacts: [APContact]?, error: NSError?) in
    if let uwrappedContacts = contacts {
        // do something with contacts
    }
    else if let unwrappedError = error {
        // show error
    }
} as! APLoadContactsBlock)

The app crash with "Thread 1: EXC_BREAKPOINT (EXC_ARM_BREAKPOINT)" but i have no idea why.

Kevin Lieser
  • 951
  • 1
  • 9
  • 25

2 Answers2

1

this fix the problem , after add NSContactsUsageDescription in your info.plist

addressBook.loadContacts { (contacts: [APContact]?, error: Error?) in
        if let unwrappedContacts = contacts {
            //your code
        }else if error != nil {
            //your code for error
        }
    }
miguelzolk
  • 63
  • 1
  • 1
  • 6
0

Firstly check if APAddressBook is supporting Swift 3. Then read carefully description of the framework.

Warning for iOS 10.0 and after

To protect user privacy, an iOS app linked on or after iOS 10.0, and which accesses the user’s contacts, must statically declare the intent to do so. Include the NSContactsUsageDescription key in your app’s Info.plist file and provide a purpose string for this key. If your app attempts to access the user’s contacts without a corresponding purpose string, your app exits.

Oleg Gordiichuk
  • 15,240
  • 7
  • 60
  • 100
  • APAddressBook is an Objective C library - what do you mean with "supporting Swift 3"? I am including APAddressBook via Bridging Header. Since it is iOS 10 ready it should work, or am i wrong? I have already read the hint and included "NSContactsUsageDescription" but the is still crashing. – Kevin Lieser Sep 12 '16 at 10:38