Failing to integrate a Swift and Objective-C framework

痞子三分冷 提交于 2019-12-11 07:58:23

问题


I'm trying to add swift support to an existing Objective-C based framework and I'm running into compilation errors when integrating the framework into the app (the framework alone builds fine).

My goal is to be able to access from swift, Objective-C project headers and to achieve this I've been using a modulemap file to list all the project files as indicated for example here: http://nsomar.com/project-and-private-headers-in-a-swift-and-objective-c-framework/

My directory structure is as follow:

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

The module.modulemap file looks like this:

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

foo is public, bar and baz have project membership instead. If bar.h includes foo (e.g. #import "Foo.h"), building the app fails with the following error:

<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'

Any idea of what I'm doing wrong? Because I'm not sure why importing that public header is causing this sort of error.

来源:https://stackoverflow.com/questions/53163988/failing-to-integrate-a-swift-and-objective-c-framework

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!