Swift Compiler Error: Use of unresolved identifier 'name'

后端 未结 5 1938
被撕碎了的回忆
被撕碎了的回忆 2020-12-11 14:34

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

Swift Compiler Error: Use of unresolved identifier \'name\'

The class exists

相关标签:
5条回答
  • 2020-12-11 15:16

    Got problem solved by

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

    0 讨论(0)
  • 2020-12-11 15:23

    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.
    0 讨论(0)
  • 2020-12-11 15:27

    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.

    0 讨论(0)
  • 2020-12-11 15:28

    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.

    0 讨论(0)
  • 2020-12-11 15:29

    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

    0 讨论(0)
提交回复
热议问题