3

我正在尝试向现有的基于 Objective-C 的框架添加 swift 支持,并且在将框架集成到应用程序时遇到编译错误(仅框架构建良好)。

我的目标是能够从 swift、Objective-C 项目标头中访问,为了实现这一点,我一直在使用 modulemap 文件来列出所有项目文件,如下所示:http: //nsomar.com/project- and-private-headers-in-a-swift-and-objective-c-framework/

我的目录结构如下:

MyFramework  
 Folder1  
      baz.h  
      baz.m  
      Folder2  
           bar.h  
           bar.m  
 foo.h  
 foo.m  
 SwiftClass.swift  
 MyFramework.h  
 module.modulemap

module.modulemap 文件如下所示:

module MyFramework_Internal {  
header "Folder1/Baz.h"  
header "Folder1/Folder2/Bar.h"  
export *
} 

foo是公开的,barbaz有项目成员资格。如果bar.h包含foo(例如#import "Foo.h"),则构建应用程序将失败并出现以下错误:

<module-includes>:2:9: note: in file included from <module-includes>:2:
#import "Folder1/Folder2/Bar.h"  
         ^
.../Folder1/Folder2/Bar.h:10:9: error: 'Baz.h' file not found  
#import "Baz.h"  
         ^  
<unknown>:0: error: could not build Objective-C module 'MyFramework_Internal'

知道我做错了什么吗?因为我不确定为什么导入该公共标头会导致这种错误。

4

0 回答 0