Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
2.6k views
in Technique[技术] by (71.8m points)

xcode - XCode6: Receiving error "Include of non-modular header inside framework module"

I have an iOS app that consists of an app, a bunch of my custom frameworks, and a bunch of third party framweorks:

App
    MyFramework1
    MyFramework2
        AFNetworking.framework
        Mantle.framework
        ..

I get the error "Include of non-modular header inside framework module" with the following structure:

App/AppDelegate.m
#import <MyFramework2/MyFramework2.h>

MyFramework2/MyFramework2.h
#import "MyClass.h"

MyClass.h
#import <Mantle/Mantle.h>        <-- Error happens here

MyFramework2 builds by itself.

Trying to build App fails with the error "Include of non-modular header inside framework module" at the line that imports Mantle.h.

This issue goes away if I import Mantle.h in the .m file, but I can't do that because my class inherits from MTLModel, which is defined in Mantle.

This issue has been addressed here, but it isn't Swift-specific.

Suggestions there are (1) make sure all custom framework headers are public. They are. And (2) go to Build Settings under "Target" and set "Allow Non-modular Includes in Framework Modules" to YES.

Does anyone know why this is happening and how to fix it? Is setting "Allow Non-modular Includes in Framework Modules" to YES considered a good practice? Why is this an error?

Thanks.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Select the .h file in the project navigator. In the target membership area on the right there is a drop down menu next to the target. Select "public" there (probably "project" is selected right now).

enter image description here


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...