azmeuk
azmeuk

Reputation: 4506

How to make a custom pod library depending on Firebase pods?

I have a very simple swift 3 pod library depending on Firebase pod. It has been created with pod lib create and the only line of code in the library is import Firebase. Still, Firebase does not seem to be detected.

-> FoobarLib (0.1.0)
    - ERROR | [iOS] xcodebuild: Returned an unsuccessful exit code. You can use `--verbose` for more information.
    - ERROR | [iOS] xcodebuild:  ~/FoobarLib/Classes/Foobar.swift:1:8: error: no such module 'Firebase'

I suppose my .podspec file is not properly configured. I have tried a simple pod dependency with s.dependency Firebase and I have tried to embed the Firebase frameworks in my library. I have played with FRAMEWORK_SEARCH_PATHS, USER_HEADER_SEARCH_PATHS, SWIFT_INCLUDE_PATHS, but I never got something working.

My sample library is hosted on github and the full error log is available on Travis. Feel free to clone it, and test pod lib lint and pod install --project-directory=Example.

I saw this related cocoapods bug report involving cocoapods guys and firebase guys, but there is no working example in it.

What should I put in my .podspec file so:

Upvotes: 2

Views: 1139

Answers (1)

Morgan Chen
Morgan Chen

Reputation: 1217

Even if you manage to get pod lib lint to pass, you'll run into issues integrating Firebase as a dependency of a dependency because it's currently vended as a static library. FirebaseUI works around this by distributing binaries instead of having CocoaPods build from source, but it's not without its own caveats (i.e. people who use FirebaseUI cannot also use another library that depends on Firebase and correctly resolve the version of Firebase that should be used). The issue you linked discusses this in more detail.

If you would really like to distribute a library that wraps Firebase through CocoaPods, you should follow the same approach, though it's worth noting that pod lib lint fails for FirebaseUI even though it ships anyway.

CocoaPods will soon (as of Oct 2017) add a rule that allows for static frameworks to be built on top of other static frameworks, including closed-source ones. This will make it much easier to build objc libs on top of other closed static objc libs, but Swift static library support is still in the works.

Upvotes: 4

Related Questions