Include of non-modular header inside framework module
I am using Xcode 6,
1) Firstly I am creating a dynamic library (CoreLibrary). This library contain RequestPoster.h file.
2) Then I create a Cocoa Touch Framework and added this dynamic library (CoreLibrary).
3) Then this framework is add on my project and it gives error in RequestPoster.h file (CoreLibrary).
Error : Include of non-modular header inside framework module class :
ifaddrs.h, arpa/inet.h, sys/types.h>
These file not found in the project.
Solution 1:
Make sure the header files are publicly available as part of the framework's public headers.
Goto Framework -> Target -> Build Phases and drag to move the relevant header files from Project to Public. Hope that helps!
Solution 2:
Try going Build Settings under "Target" and set "Allow Non-modular Includes in Framework Modules" to YES.
The real answer is that the location of the imports needs to be changed by the library owner. Those files ifaddrs.h, arpa/inet.h, sys/types.h are getting imported in a .h file in a framework, which Xcode doesn't like. The library maintainer should move them to a .m file. See for example this issue on GitHub, where AFNetworking fixed the same problem: https://github.com/AFNetworking/AFNetworking/issues/2205
Solution 3:
You can set Allow Non-modular includes in Framework Modules in Build Settings for the affected target to YES. This is the build setting you need to edit:
NOTE: You should use this feature to uncover the underlying error, which I have found to be frequently caused by duplication of angle-bracketed global includes in files with some dependent relationship, i.e.:
#import <Foo/Bar.h> // referred to in two or more dependent files
If setting Allow Non-modular includes in Frame Modules to YES results in a set of "X is an ambiguous reference" errors or something of the sort, you should be able to track down the offending duplicate(s) and eliminate them. After you've cleaned up your code, set Allow Non-modular includes in Frame Modules back to NO.
Solution 4:
I had the same problem and solve it by just making header file public.
If you are working on multiple modules in your project. Then your header file needs to be public to be used in other parts of projects. What you need is to select that header file, and in project Utilities view. Change the file from Project/Private to Public. See image below:
Solution 5:
"Include of non-modular header inside framework module"
When you get this error the solution in some circumstances can be to simply to mark the file you're trying to import as "public" in the file inspector "Target Membership". The default is "Project", and when set this way it can cause this error. That was the case with me when trying to import Google Analytic's headers into a framework, for example.