I know this has been asked multiple times (see here, here, or here).. but they're mostly working with statically linked libraries. In my case, I'm trying to use iOS8+'s dynamically linked frameworks:
Here's my project structure:
platform :ios, '8.1'
use_frameworks!
target :MyProject do
#pod 'PromiseKit'
pod 'MyDynamicFramework', :path => '../MyDynamicFrameowork'
end
Pod::Spec.new do |s|
[..]
s.dependency 'PromiseKit'
[..]
end
I typically import my framework via its umbrella header, like so:
#import <MyDynamicFramework/MyDynamicFramework.h>.
However, it so happens that not only my framework requires PromiseKit but also my actual project. I got weird no known class method for selector errors initially but I was able to get rid of those as long as I would #import PromiseKit BEFORE importing my framework's umbrella header, like so:
#import "RandomViewController.h"
// WORKS:
#import <PromiseKit/PromiseKit.h>
#import <MyDynamicFramework/MyDynamicFramework.h>
// DOES NOT WORK:
//#import <MyDynamicFramework/MyDynamicFramework.h>
//#import <PromiseKit/PromiseKit.h>
@implementation RandomViewController
[..]
@end
While my project now actually compiles and runs, I have hundreds of Duplicate definition of category 'PromiseKit' on interface '*' warnings... If I expand the warning I get
In module 'MyDynamicLibrary'
Imported from /Users/..../Builds/Products/iphone-simulator/MyDynamicLibrary.framework/headers/SomeFrameworkClass.h:10
Is there anything obvious I'm missing here?
PS: I added an example project for reference: https://github.com/opfeffer/CocoaPodsTest
What happens if you change the imports to modular imports, i.e. @import?
I can't repro this issue with your example project, if I remove the PromiseKit import from your view controller, it just works as expected.
Possibly the difference is that the Podfile you have in the issue has the PromiseKit dependency commented out for your application target whereas the example does not.
If you directly use a transitive dependency somewhere, you have to explicitly specify it when using frameworks.
got the same problem. My solution is to remove the inclusion of all duplicated category headers. It's not exactly a solution, but I don't really need those third party category headers anyway.
I also started seeing
"/Pods/Headers/Public/FirebaseAnalytics/FirebaseAnalytics/FIRAnalytics+AppDelegate.h:19:12: Duplicate definition of category 'AppDelegate' on interface 'FIRAnalytics'"
as a warning after switching to "use_modular_headers!" instead of "use_frameworks!"
CocoaPods version 1.5.3
Firebase version 5.15.0
Most helpful comment
What happens if you change the imports to modular imports, i.e.
@import?