14

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.

1 Answer 1

15

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

Sign up to request clarification or add additional context in comments.

7 Comments

Note this is a problem even if you have turned on the CLANG setting for "Allow Non-modular Includes In Framework Modules", which your answer solves. Thanks.
@Nikos M. can you please add a screenshot. I cant see that dropdown. Please help. Many thanks
Where is the dropdown menu for target membership?
@lenhhoxung it is not a dropdown menu. It's in the right sidebar with the properties.
@NikosM. Thanks, but it's not applicable for me because the header file is installed via cocoapods
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.