-2

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

benc
  • 1,381
  • 5
  • 31
  • 39
Emre Gürses
  • 1,992
  • 1
  • 23
  • 28
  • Not enough information. Please don't just show some dribs and drabs from your code. Figure out what is _all_ the code needed to _reproduce_ the issue and show that. (For example, make a plain vanilla new project and add just enough code to it to reproduce the problem yourself, and then describe or post that project.) – matt Apr 25 '18 at 15:47
  • Hi @matt , i can't paste all code/project. i try to explain my problem with code snipped, screenshot and expression. I think, you can not reproduced this problem because of its related project file which is "import loop". if you want to specific info, you can ask. – Emre Gürses Apr 25 '18 at 17:33
  • I did ask. You are using a lot of type names that you have not explained. Explain them. – matt Apr 25 '18 at 17:34
  • i added ContactsDelegate protocol which is extended from CNContactPickerDelegate. – Emre Gürses Apr 25 '18 at 17:49
  • Is the problem that you expect MoneyTransferToGsmVC to know about ContactsDelegate? But it cannot because you did not mark it `@objc`. Same for your extension. What is not marked `@objc` is hidden from Objective-C. – matt Apr 25 '18 at 18:11
  • So, where should I write "@objc" – Emre Gürses Apr 25 '18 at 19:15
  • Uh... In front of everything you need Objective-C to see. – matt Apr 25 '18 at 19:25

1 Answers1

0

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.

Emre Gürses
  • 1,992
  • 1
  • 23
  • 28