Swift compiler error: “non-modular header inside f

2019-01-02 16:43发布

Now I would like to migrate my ObjC framework to Swift and I got the following error:

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

The references is to a header file which just define a protocol and I use this header file in some classes to use this protocol.

Is seems related to the module feature but it is at the moment not quite clear how to fix, do you know a solution?

UPDATE:

This is a Swift compiler error.

UPDATE 2:

A quick fix (but not solving the root cause) is to set the following setting to yes: CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES = YES

20条回答
深知你不懂我心
2楼-- · 2019-01-02 17:22

Don't

#import "MyOtherFramework.h"

Do

#import <MyOtherFramework/MyOtherFramework.h>
查看更多
十年一品温如言
3楼-- · 2019-01-02 17:23

I had this problem importing the Parse framework. The only way I could fix it was to discard all my changes since my last commit (simply deleting the framework and cleaning the project did not work) and add Parse again (after a fresh download of the SDK) with its other required frameworks.

查看更多
忆尘夕之涩
4楼-- · 2019-01-02 17:24

Solution for me was to go on target-> build settings->Allow non-modular includes in Framework Modules switch to YES!

查看更多
墨雨无痕
5楼-- · 2019-01-02 17:25

I solved it removing Modules folder from the framework.

  • Browse to your framework location which is present in the App Project using finder

  • Go inside Test.framework folder (In the above case it will be SOGraphDB.framework) & Delete Modules folder.

  • Clean and Re Build the app, it will solve the problem.

查看更多
闭嘴吧你
6楼-- · 2019-01-02 17:27

I got this problem after updating a project from swift2 to swift3. I was using XCode 8.3.2 to update the code and could not get rid of the error “non-modular header inside framework module”. When I opened the same project in another version of XCode (version 9.0.1) the error did not appear.

查看更多
皆成旧梦
7楼-- · 2019-01-02 17:29

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.

查看更多
登录 后发表回答