现在我想把我的ObjC框架迁移到Swift,我得到了以下错误:

include of non-modular header inside framework module 'SOGraphDB'

引用是一个头文件,它只是定义了一个协议,我在一些类中使用这个头文件来使用这个协议。

这似乎与模块特性有关,但目前不太清楚如何修复,你知道解决方案吗?

更新:

这是一个Swift编译器错误。

更新2:

一个快速的解决方法(但不能解决根本原因)是将以下设置设置为yes: clang_allow_non_modular_incles_in_framework_modules = yes


当前回答

#import "MyOtherFramework.h"

Do

#import <MyOtherFramework/MyOtherFramework.h>

其他回答

Most commonly this error is caused by the chosen answer, yet I had this error appear once by accident when dragging framework files into my new project folder. I clicked to delete the frameworks but accidentally pressed to only 'Remove Reference' to the frameworks rather than to actually delete the files completely. At this point if I opened my project folder in Finder I saw files like 'CoreLocation' and 'AudioToolbox' there. Deleting these files from the project folder and cleaning the project fixed the issue.

迅速:

1. 修改你的Xcode项目和目标的构建设置如下所示:

允许非模块包含在框架模块中

Enable Bitcode:是

2. 使用当前最新版本的GoogleMaps iOS SDK(使用CocoaPods获取):

谷歌地图 (1.10.4)

3.注释有问题的导入:

//import GoogleMaps

4. 创建或修改桥接头文件,添加有问题的导入:

[你的Xcode项目名称]-Bridging-Header.h

// Use this file to import your target's public headers 
// that you would like to expose to Swift.
#import <GoogleMaps/GoogleMaps.h>

5. 清理并重新构建Xcode项目。

头文件已分配给目标,但仅被标记为项目可见,只是更改为公共导致解决此错误。

在我的情况下(Xcode 9 beta 6 - Swift 4 -使用Cocoapods),当我删除Podfile时,这个问题得到了解决。然后再次运行pod install

允许框架模块中的非模块化包含为YES!为我解决了同样的问题。