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:31

I had the specific problem with Facebook 4.02 sdk and FBSDKCoreKit.

I did all the steps but still error about non modular header. i drag and dropped only the specific header from the framework to build phases-> header section.

Then automatically created a copy of the header on the project navigator at the top.

I removed it from the build phases -> header and deleted the new file and worked fine.

Like it reseted or something.

查看更多
与风俱净
3楼-- · 2019-01-02 17:31

Switching Build settings > Allow non-modular includes in Framework Modules to YES! solved the same issue for me.

查看更多
春风洒进眼中
4楼-- · 2019-01-02 17:32

After allowing to import non modular includes, you could try to import that module using Objective-C Bridging header:

#import <YandexMobileMetrica/YandexMobileMetrica.h>
查看更多
只靠听说
5楼-- · 2019-01-02 17:34

The header file was allocated to the target but was only marked as project visible, just a change to public lead to the resolution of this error.

查看更多
与君花间醉酒
6楼-- · 2019-01-02 17:36

Here's how to automatically apply the quick fix so you don't have to change Pods.xcodeproj manually after each pod install.

Add this snippet to the end of your Podfile:

post_install do |installer|
  installer.pods_project.build_configuration_list.build_configurations.each do |configuration|
    configuration.build_settings['CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES'] = 'YES'
  end
end
查看更多
君临天下
7楼-- · 2019-01-02 17:36

In my case (Xcode 9 beta 6 - Swift 4 - using Cocoapods) this was solved when I deleted Podfile.lock and the Pods directory and ran pod install again

查看更多
登录 后发表回答