segment-integrations / analytics-ios-integration-firebase

Segment's bundled integration for Firebase on iOS
MIT License
13 stars 92 forks source link

Adds subspec workaround. #23

Closed ladanazita closed 6 years ago

ladanazita commented 6 years ago

This workaround to Cocoapods Static Library/Framework.

The limitation occurs when an application is built in Swift, you are including use_frameworks! in your podfile, and are using a transitive dependency that is provided as a static library or framework.

The current workaround (as outlined in this subspec) is to copy the integration code manually into your project, then depend on Firebase directly. Instead of importing the integration from our library you would import the integration from your local copy. This eliminates the transitive dependency from the App -> Segment-Firebase -> Firebase to App -> Firebase.

Tested with the following configurations

Without use_frameworks!

With use_frameworks!

CC @TeresaNesteby

ladanazita commented 6 years ago

Tested end to end here: https://github.com/segmentio/analytics-test-apps/tree/firebase_staticLib

Steps to implement this solution:

Podfile

target 'AnalyticsIOSTestApp' do
  pod 'Analytics'
  pod 'Firebase'
  pod 'Segment-Firebase/StaticLibWorkaround'
end

Run pod install

In your app, you will see that Pods > Segment-Firebase is empty.

screenshot 2018-04-02 14 26 58

Right click and Show in Finder screenshot 2018-04-02 14 27 05

You will see the Classes > SEGFirebaseIntegration files. Drag and drop them into the top level of your iOS App Make sure Create groups is selected

screenshot 2018-04-02 14 27 32

Then update your bridging header:

#import "SEGFirebaseIntegrationFactory.h"

And follow the normal steps to import the integration into your AppDelegate.swift:

#import "SEGFirebaseIntegrationFactory.h"
config.use(SEGFirebaseIntegrationFactory.instance())
f2prateek commented 6 years ago

If the customer has to copy the files for this integration into their project, what purpose does pod 'Segment-Firebase/StaticLibWorkaround', :path => '../' serve?

I think they could just copy those files and do pod 'Firebase' and it would still work without pod 'Segment-Firebase/StaticLibWorkaround', :path => '../'?

ladanazita commented 6 years ago

@f2prateek It's just convenient and still allows them to "pull in" the files from a Cocoapods pod install vs navigating to the Github repo

f2prateek commented 6 years ago

Gotcha.

ladanazita commented 6 years ago

🎉 Congrats

🚀 Segment-Firebase (2.2.0) successfully published 📅 April 2nd, 15:44 🌎 https://cocoapods.org/pods/Segment-Firebase 👍 Tell your friends!

Fawxy commented 6 years ago

Do we need the full pod 'Firebase' or is pod 'Firebase/Core' enough?