Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Swift Compiler Error: Use of unresolved identifier 'name'

I tried to include a class called 'name' and I got an error:

Swift Compiler Error: Use of unresolved identifier 'name'

The class exists and doesn't contain any compile errors.

like image 300
Vojtech Vrbka Avatar asked Sep 29 '14 11:09

Vojtech Vrbka


3 Answers

There could be a few possible issues.

  1. One of the classes has a Testing target and other one doesn't. You have to even include all of your classes in the testing target or none of them.

  2. If it's Objective C class, check that the class is in ObjectiveC bridging header file.

  3. If it's NSManagedObject subclass. Add @objc(className) before the class declaration.

  4. If it's part of a different framework, make sure that the class or function is public

like image 136
Vojtech Vrbka Avatar answered Oct 31 '22 07:10

Vojtech Vrbka


I had this one too. You will probably find that your first class is included in your testing module and that "name" isn't. Simply, if you include a class in testing, then every class that it references has to be in testing.

like image 6
Owen Godfrey Avatar answered Oct 31 '22 07:10

Owen Godfrey


I had this problem too. I was trying to reference Class 1 within the code in Class 2. My problem was that Class 2 had target memberships in A and B, and Class 1 only had Target Memberships in Class A.

You can fix this by opening the Utilities Tab (farthest right button on the top bar of the Xcode window), and make sure that the same boxes are checked for both classes in the Target Membership subsection.

like image 6
Binya Koatz Avatar answered Oct 31 '22 08:10

Binya Koatz