Swift Compiler Error: Use of unresolved identifier 'name'

◇◆丶佛笑我妖孽 提交于 2019-11-28 13:16:42

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

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.

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.

Got problem solved by

Target -> Build Phases -> Compile Sources -> Adding the class file

Add one more to the list.

  1. If it is part of another framework, make certain that the "Build Active Architecture Only" settings are the same.
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!