I have created an open source library (https://github.com/linkedin/LayoutTest-iOS) which has two Cocoapods inside - LayoutTest and LayoutTestBase. LayoutTest depends on LayoutTestBase and one of the .h files needs to import something from LayoutTestBase. Currently, I do this using:
@import LayoutTestBase;
However, this only works if the application uses use_frameworks!
in their Podfile. Some apps do not want to use this cocoapods option. Without use_frameworks!
, it works if I use:
#import <LayoutTestBase/LYTLayoutPropertyTester.h> // OR
#import "LYTLayoutPropertyTester.h"
However, when using this with use_frameworks!
, it gives the error: "Include of non-modular header inside framework module 'LayoutTest.LYTLayoutTestCase'"
Clearly, there should be a way of doing this import regardless of whether the user uses use_frameworks!
or not in their Podfile. How can I get this library to compile and run correctly?
Research
I've looked on stackoverflow, and this seems to be the most similar question: CocoaPods framework with dependencies - include of non-modular header inside framework module. It mentions that it's a problem with the Parse library, but doesn't mention how it needs to be fixed. Since I own the dependency, I can fix this. I've also tried setting Allow non-modular frameworks to YES in all settings (projects, unit tests, all pods, etc), and this doesn't seem to do anything.
To Reproduce
Create a new project. Add this Podfile:
target :'{MyAppTarget}Tests' do
pod 'LayoutTest'
end
Run pod install
. Try to run unit tests on the app. It will fail. Now, try changing LYTLayoutTestCase.h to use #import <LayoutTestBase/LYTLayoutPropertyTester.h>
. It now works. However, if you add use_frameworks!
to the Podfile, it no longer works.