swift header file cannot find protocol declaration for 'CNContactPickerDelegate'

553 Views Asked by At

I am trying added enough code and information that related this problem.

I want to use native Contact list to get phone numbers. So, i prefer to use "Contacts" framework which is supported iOS9 and above.

When i added these delegates method to my code. I am getting error from Swift header file(ProjectName-Swift.h file). I was googling but I did not find any solutions. I am prety sure, "Contacts" framework caused "import loop" problem. Anyone has any suggestons?

// Calling CNContactPickerViewController method

func clickedAdressBook() {
    let contactPicker = CNContactPickerViewController()
    contactPicker.delegate = self
    self.present(contactPicker, animated: true, completion: nil)
}

// to handle ContactsDelegate delegate metods

extension MoneyTransferToGsmVC : ContactsDelegate {
}

To solve this problem, i created new protocol which extended from CNContactPickerDelegate. But it's not worked

    import UIKit
import Foundation
import Contacts
import ContactsUI

protocol ContactsDelegate : CNContactPickerDelegate {

}

When i added above extension, i am getting below error.

enter image description here

1

There are 1 best solutions below

0
On

i found a solution.

i know, this answer is a not good option. But it's work to me.

Firstly create a new .h file to copy "Swift Header File". In my case i created "ProjectName-SwiftFixed.h".

Then, instead of #import "ProjectName-Swift.h" in my code,i use #import "ProjectName-SwiftFixed.h.