本文介绍了具有混合的Swift和Objective-c项目的Xcode 8生成了"ModuleName-Swift.h".找不到标题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个在Xcode 8中混合使用Swift和Objective-C的项目,该项目使用生成的"ModuleName-Swift.h"头文件将swift导入到Objective-c类中,但是预处理器无法找到生成的头文件,并在导入时引发错误.

I have a project with mixed Swift and Objective-C in Xcode 8 that uses the generated "ModuleName-Swift.h" header file to import swift into Objective-c classes, but the preprocessor is not able to find the generated header file and throws an error on the import.

词汇或预处理器问题:'找不到ModuleName-Swift.h文件'"

"Lexical or Preprocessor issue : 'ModuleName-Swift.h file not found'"

该项目可以正常编译,但是预处理器会因未找到标头而引发错误,并且对于在该类内部调用的任何Swift类,都不会突出显示语法或完成代码.在Xcode 8无法识别的Objective-c中使用Swift类工作是很费力的,但是编译起来还不错.

The project compiles just fine, but the preprocessor throws errors for the header not being found and for any Swift classes called inside the class there is no syntax highlighting or code completion. It's a struggle working with Swift classes in Objective-c that are unrecognized by Xcode 8, but yet compile just fine.

关于如何安抚Xcode 8中的预处理器的任何想法?

Any ideas on how to appease the preprocessor in Xcode 8?

推荐答案

我遇到了完全相同的问题.在添加了一个仅针对一个目标的新文件(错误地)并注意到读取Swift类没有问题后,找到了解决方案.因此,如果您有多个目标,并且由于迁移,则无需构建和运行它们,建议您这样做.

I had exactly the same issue. Found the solution after adding a new file aiming to only one target (by mistake) and noticing that it had no problem reading the Swift classes. So, if you have multiple targets, and since the migration you didn't have the need to build and run them, suggest you to do that.

这篇关于具有混合的Swift和Objective-c项目的Xcode 8生成了"ModuleName-Swift.h".找不到标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-30 08:56