Alterplay / APAddressBook

Easy access to iOS address book
MIT License
1.38k stars 193 forks source link

Do not work with XCode 8.0 / Swift 3 #137

Closed kevinlieser closed 7 years ago

kevinlieser commented 7 years ago

I am trying to fetch the contacts as always (same as your Swift example):

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)

But it exits with "Thread 1: EXC_BREAKPOINT (EXC_ARM_BREAKPOINT)". Anybody get that to work?

belkevich commented 7 years ago

Sorry, but we didn't check APAddressBook compatibility with Swift 3.0. I'll do it after XCode 8 release.

0-mykola commented 7 years ago

iOS 10: You need to put the NSContactsUsageDescription in your plist. Like:

<key>NSContactsUsageDescription</key>
<string>$(PRODUCT_NAME) uses contact list</string>

See all usage descriptions here.

Kamasoutra commented 7 years ago

I've already made that change but I still got the same issue as @kevinlieser

Did you actually make it work this way ? I've maybe done something wrong :/

kevinlieser commented 7 years ago

I've defined the plist setting for NSContactsUsageDescription, too. Not working at all. A simple test with the new Contact Framework reads this setting, too. And it works.

0-mykola commented 7 years ago

U should use correct code:

        self.addressBook.loadContacts { (contacts: [APContact]?, error: Error?) in
            if let uwrappedContacts = contacts {
                // do something with contacts
            }
            else if let unwrappedError = error {
                // show error
            }
        }
0-mykola commented 7 years ago

sorry, but I create new project in xcode 8, and add via pods this framework, and use example from main page, where I got an error. Xcode trying to update code like in ur example, with } as! APLoadContactsBlock) but after build&run I have a crash with Thead 1: EXC_BAD_INSTRUCTION (code=EXC_I386... Its mean inside exception

but if u try to add loadContacts function with completion block use xcode "intellisense" u will see a difference.

PS: I use this library in objective-c project, and Im trying to help with this issue.

kevinlieser commented 7 years ago

@adman44: You code works like a charm. Thanks a lot! I've deleted my nonsense comment :-)

abusetrouble commented 7 years ago

@adman44 Thanks you. This helps me, I got a sigabrt error when requesting access

thefinnomenon commented 7 years ago

@adman44 thanks! your code worked perfectly.

belkevich commented 7 years ago

Check out new release - 0.3.0 I've removed type aliases in callbacks. Know it should work better with xcode's Swift3 autocomplete