3

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.

Glauco
  • 495
  • 1
  • 7
  • 17
  • try like #import "../../Foo.h" if you import from bar.h. – Razib Mollick Nov 06 '18 at 00:52
  • I'm importing from baz.h and "../Foo.h" works! What I don't understand is why do I need to do that? Is it because Foo.h is marked as public? For example, if Foo.h is private, importing like #import "Foo.h" works as well. I've been reading https://clang.llvm.org/docs/Modules.html but I can't find an obvious reason. Thanks! – Glauco Nov 06 '18 at 01:19

0 Answers0