Swift编译器错误:使用未解析的标识符'name' [英] Swift Compiler Error: Use of unresolved identifier 'name'

查看:559
本文介绍了Swift编译器错误:使用未解析的标识符'name'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图包含一个名为'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.

推荐答案

可能有几个问题。


  1. 其中一个类别具有测试目标,而其他类别则没有。

  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.

如果是Objective C类,请检查该类是否在ObjectiveC桥接中

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

如果是NSManagedObject子类。在类声明之前添加 @objc(className)

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

如果它是不同框架的一部分,请确保类或函数 public

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

这篇关于Swift编译器错误:使用未解析的标识符'name'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆