firebase / firebase-ios-sdk

Firebase SDK for Apple App Development
https://firebase.google.com
Apache License 2.0
5.47k stars 1.43k forks source link

FR: Carthage support #9

Closed okydk closed 5 years ago

okydk commented 7 years ago

Now that the Firebase SDKs are open source, can we then have Carthage support? 😍

*** Cloning firebase-ios-sdk
*** Checking out firebase-ios-sdk at "4.0.0"
*** Skipped building firebase-ios-sdk due to the error:
Dependency "firebase-ios-sdk" has no shared framework schemes
morganchen12 commented 7 years ago

We can't add Carthage support via a shared framework scheme for the time being since all the Firebase libraries have a common dependency in Analytics, which is still closed source and vended as a static library. If we were to try to distribute the other Firebase libs as dynamic frameworks, they would all have link time dependencies on Analytics and would end up duplicating the Analytics classes in the runtime, bloating app size and causing undefined behavior in some instances.

Carthage does support vending binaries, so we could still distribute these as static binaries with static dependencies on Analytics. Others wouldn't be able to easily build and redistribute libraries wrapping Firebase, but otherwise we'd retain many of the benefits of using Carthage. But before this can happen Analytics also needs to be distributed through Carthage, since mixing dependency managers is not something we should encourage developers to do.

The most straightforward solution would be to distribute Analytics as a dynamic framework through Carthage and then build the open source Firebase frameworks on top of that via a shared framework scheme. This is unlikely to happen in the very short term. In the longer term, we'd need to weigh the drawback of causing longer app launch times for dylib users versus the benefit of allowing users to install Firebase through Carthage and easily build frameworks wrapping Firebase. If you have either of these concerns (app launch times/want to build on top of Firebase), please share your thoughts!

okydk commented 7 years ago

Ok, fingers crossed for support in the future 🤞 and thanks for the clarification.

soheilbm commented 7 years ago

For time being I already created a carthage compatible for firebase. https://github.com/soheilbm/firebase

mhuusko5 commented 7 years ago

@morganchen12 I'm very much interested in building frameworks on top of Firebase, and I think the more Firebase continues to grow as a defacto database and auth/etc. solution, the more people/companies are going to be wrapping it, at least for internal use (but probably convenience frameworks at some point too). At the moment though I'm most interested in this Analytics topic. From what I can tell at first pass of the source (at least of FirebaseCore), Analytics being present is desired but not required. Is this actually/will this continue to be, the case?

salqadri commented 7 years ago

Hi @mhuusko5. Google Analytics for Firebase is what enables us to offer an integrated experience across the various other Firebase services we offer. As such we try to make Firebase Analytics included in the default experience since this is will maximize the value to our users. A great example of this is the AdMob integration with Firebase. When used together, we are able to combine metrics from both AdMob and Analytics to answer more sophisticated questions like "On which screens are users being exposed to advertising the most or the least?" However, we know that some advanced users may explicitly only want the AdMob SDK which is why we avoid having hard dependencies. So yes, since this is by design, you can expect that we will continue to only be using weak dependencies for the majority of our inter-product integrations. There are other weak dependencies in the codebase as well, such as between Database and Auth, such that Database works without it, but when Auth is included in an app its functionality is enhanced. Hope that clarifies this.

mhuusko5 commented 7 years ago

@salqadri fantastic, thanks for the breakdown, and I love the design strategy. 👍

morganchen12 commented 7 years ago

@mhuusko5 for the time being you can create frameworks wrapping Firebase for your own personal use by just embedding them in a target and using CocoaPods' inherit! :search_paths without any issues. Life becomes much harder once you try to distribute the framework afterwards.

AndrewSB commented 7 years ago

Distributing Analytics through Carthage shouldn't be too hard. For example, this is what mapbox does: https://www.mapbox.com/ios-sdk/

Relevant line in a consumer's cartfile would be binary "https://www.mapbox.com/ios-sdk/Mapbox-iOS-SDK.json" ~> 3.5, which just points to a JSON file (https://www.mapbox.com/ios-sdk/Mapbox-iOS-SDK.json ) with version numbers and a URL from where to download the .framework

I understand that it will take some time to work through the bureaucracy that comes with being at Google, so I understand that adding complete Carthage support will potentially be a long-term goal 😄 Take your time, thank you for going (almost completely) open source ❤️

morganchen12 commented 7 years ago

@AndrewSB for reference the issue here isn't Carthage, it's that we currently don't ship Analytics as a dynamic framework, which we must (should) before distributing it through Carthage.

AndrewSB commented 7 years ago

Ahh, I see. Still a static framework, I take back what I said then. So I guess we're waiting on that dynamic framework then

paulb777 commented 7 years ago

Carthage has recently added some info to its README about integrating static frameworks that could be helpful - https://github.com/Carthage/Carthage#build-static-frameworks-to-speed-up-your-apps-launch-times

TofPlay commented 7 years ago

I create some dynamic frameworks compatible with carthage for my own projects with dependencies between them. It's not really complex. And if you want to create a cross-platform framework compatible with carthage you can follow this tutorial I created: Swift Cross Platform Framework 👍

paulocoutinhox commented 6 years ago

+1

alokc83 commented 6 years ago

+1

Davtyanag commented 6 years ago

+1

monsantovernon commented 6 years ago

Still waiting for direct Carthage support.

floriangbh commented 6 years ago

+1

ghost commented 6 years ago

+1

iSevenDays commented 6 years ago

Is there any progress?

paulb777 commented 6 years ago

This PR will be updated when there is progress.

Please don't add additional comments unless you are interested in contributing to the implementation.

Use :+1: to indicate interest.

joselinoneto commented 6 years ago

+1

basememara commented 6 years ago

22u1bz

Not all of us are ok with CocoaPods molesting our project files. Stripe, Intercom, and Facebook all have beast SDK's and have Carthage support, and you're the ones supposed to be mobile dev friendly.

The manual setup is ridiculously insane and a huge barrier. The impression I get is you got something super legacy I wouldn't touch with a 10-foot pole.

mbuchetics commented 6 years ago

How is this still an open issue? Is somebody actively working on it? Carthage 0.28 supports static binaries: https://github.com/Carthage/Carthage/releases/tag/0.28.0

localredhead commented 6 years ago

+1 Analytics supports Carthage AFAIK https://github.com/segmentio/analytics-ios#carthage ?

AndrewSB commented 6 years ago

FWIW I gave this a shot last week, I couldn't believe Google would just let it sit for years and I wanted it for a project I was working on. WIP over at my fork. I ran into a small snag: to vend firebase through Carthage, google-toolbox-for-mac also needs to support Carthage. I looked into setting that up too, but that project has some strange xcscheme settings I didn't feel like unmangling. WIP over at my fork of the toolbox.

@firebase-ops: I'd love some help upgrading google-toolbox-for-mac. Maybe you can ask some of the internal maintainers to work on this? If anyone else would like to contribute, please don't hesitate to target my forks, I'd be happy to merge anything that gets the project going with Carthage

paulb777 commented 6 years ago

@AndrewSB Thanks for digging in and glad to hear you're making progress, but I'm not sure it's currently possible with Carthage to support Firebase as the mix of source static frameworks currently required to work with the Analytics and InstanceID binary static framework dependencies.

I'm currently working on making a pure binary Firebase Carthage distribution derived from the Firebase zip distribution and planning to make it publicly available in the near future.

AndrewSB commented 6 years ago

@paulb777 thats great to hear, that does seem like the complete solution. Keep us updated on how that's going. Like I mentioned last year, it should be as simple as creating a JSON file like https://www.mapbox.com/ios-sdk/Mapbox-iOS-SDK.json once the releases are uploaded in a standard way

schlingding commented 6 years ago

paulb777 commented 6 years ago

An experimental binary Carthage Firebase distribution is now available including all of Firebase except Firestore and Invites. Details at https://github.com/firebase/firebase-ios-sdk/blob/master/Carthage.md.

I've also created a new github Carthage label for any specific issues or feedback.

olejnjak commented 6 years ago

I think this is just fine but can we expect Firestore support in near future?

paulb777 commented 6 years ago

@olejnjak Firestore has a dependency on gRPC which has resources and I couldn't figure out how to get the Carthage installer to install resources for a binary component. Any ideas?

AndrewSB commented 6 years ago

@paulb777 are you talking about https://github.com/grpc/grpc? Can you be more specific with the resources that are required? Also, the folks over at Carthage are usually pretty helpful. If you aren't sure how to do this, creating an Issue there will probably get you an answer

paulb777 commented 6 years ago

@AndrewSB Specifically gRPC/etc/roots.pem from https://github.com/grpc/grpc.

I couldn't find a place to put it in the zip without being ignored by the Carthage installer.

The next time I have bandwidth for Carthage, I'll take another stab at it and make an issue. In the meantime, suggestions and contributions are welcome.

paulb777 commented 6 years ago

Thanks to @blender for help with Carthage binary resource installation.

karlpuusepp commented 6 years ago

We're seeing a linker warning when using Firebase with Carthage

ld: warning: Auto-Linking framework linker option at .../Carthage/Build/iOS/Firebase.framework/Firebase is not a dylib and not an archive

Any clue what's causing this? It still appears when Link frameworks automatically is disabled.

olejnjak commented 6 years ago

@rerelease do you link empty Firebase.framework? You shouldn't https://github.com/firebase/firebase-ios-sdk/blob/master/Carthage.md#carthage-usage

Delete Firebase.framework from the Link Binary With Libraries Build Phase.

karlpuusepp commented 6 years ago

Nope, already checked that. It's neither linked nor embedded with the app target.

It seems that replacing all import Firebase statements with import FirebaseAnalytics seems to get rid of the warning.

Drusy commented 6 years ago

Having the same problem @rerelease, having the import Firebase statement produces this warning. Replacing with any other library works import FirebaseCore for example or import FirebaseAnalytics.

paulocoutinhox commented 6 years ago

How to add this repository to Carthage? Only need paste that lines "binary ..." to the Cartfile?

floriangbh commented 6 years ago

How to add this repository to Carthage? Only need paste that lines "binary ..." to the Cartfile?

README : https://github.com/firebase/firebase-ios-sdk/blob/master/Carthage.md#carthage-usage

paulocoutinhox commented 6 years ago

I already read, but what mean "create a subset"? I paste it to Carfile and testing now. Thanks.

paulb777 commented 6 years ago

@prsolucoes Does #1061 answer your question?

paulocoutinhox commented 6 years ago

Yes. In my opinion, i think that something more clear as "paste de following lines into your Cartfile" will be easier to carthage newbies like me auhahuahuahuahua. But i understand that is paste lines and im testing now.

paulocoutinhox commented 6 years ago

Hi,

After include this reps:

binary "https://dl.google.com/dl/firebase/ios/carthage/FirebaseAnalyticsBinary.json"
binary "https://dl.google.com/dl/firebase/ios/carthage/FirebaseMessagingBinary.json"

And carthage build, i have include the frameworks, but got error:

Invalid architecture: Could not read architectures from /Users/paulo/Developer/workspaces/xcode/xxx/Carthage/Build/iOS/FirebaseCoreDiagnostics.framework
Command /bin/sh failed with exit code 1
kasyanov-ms commented 6 years ago

I've just deleted that framework, and all works well

paulocoutinhox commented 6 years ago

I can ignore it? Remove it from my build and copy-framework?

paulocoutinhox commented 6 years ago

Today im using all of this:

image

To use Analytics and Messaging parts.

kasyanov-ms commented 6 years ago

We need someone of the contributors to confirm it is safe to remove FirebaseCoreDiagnostics.framework

paulocoutinhox commented 6 years ago

I have removed it too, now its compile, but when i go install i receive this message on simulator and on device:

image

paulb777 commented 6 years ago

@kasyanov-ms @prsolucoes I deployed Firebase 4.12.0 to Carthage and fixed the FirebaseCoreDiagnostics error in the process.

I'm not able to reproduce the "This app could not be installed at this time." issue. If that's still occurring for you, please create another issue with details on how to reproduce.