firebase / firebase-ios-sdk

Firebase SDK for Apple App Development
https://firebase.google.com
Apache License 2.0
5.51k stars 1.44k 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
paulocoutinhox commented 6 years ago

Hi @paulb777, Thanks for the update. But FirebaseCoreDiagnostics is needly or not?

paulocoutinhox commented 6 years ago

Now with the new version everything is working and compiling, but when i run i get the error:

image

olejnjak commented 6 years ago

@prsolucoes i think that this might be some problem with your project configuration...

paulocoutinhox commented 6 years ago

@olejnjak @paulb777 No guys, dont be a problem here. I create an empty and simple new project, add carthage file, download the frameworks, link into the project and the same problem happen. If i remove all from firebase, the project back to work:

The repository that i create only to test firebase and carthage: https://github.com/prsolucoes/firebase

paulocoutinhox commented 6 years ago

@olejnjak @paulb777 Hi. I made more command line tool in my sample project (https://github.com/prsolucoes/firebase). After run on simulator (make run-simulator) i got error:

ios-sim launch ./build/Build/Products/Debug-iphonesimulator/FirebaseTest.app --devicetypeid=iPhone-7
An error was encountered processing the command (domain=IXUserPresentableErrorDomain, code=1):
This app could not be installed at this time.
Underlying error (domain=MIInstallerErrorDomain, code=57):
    Found bundle at /Users/paulo/Library/Developer/CoreSimulator/Devices/CE49D8E9-CC06-4398-9ED1-D11DB21B64C9/data/Library/Caches/com.apple.mobile.installd.staging/temp.NvZWu9/extracted/FirebaseTest.app/Frameworks/FirebaseCore.framework with the same identifier (com.firebase.Firebase) as bundle at /Users/paulo/Library/Developer/CoreSimulator/Devices/CE49D8E9-CC06-4398-9ED1-D11DB21B64C9/data/Library/Caches/com.apple.mobile.installd.staging/temp.NvZWu9/extracted/FirebaseTest.app/Frameworks/Protobuf.framework

I think that it can be a clue.

All frameworks has the same bundle-id:

paulo@Paulos-MacBook-Pro:~/Developer/workspaces/xcode/FirebaseTest (master) $ grep -R "com.firebase.Firebase" .
./Carthage/Build/iOS/Protobuf.framework/Info.plist: <string>com.firebase.Firebase</string>
./Carthage/Build/iOS/Firebase.framework/Info.plist: <string>com.firebase.Firebase</string>
./Carthage/Build/iOS/FirebaseCore.framework/Info.plist: <string>com.firebase.Firebase</string>
./Carthage/Build/iOS/FirebaseAnalytics.framework/Info.plist:    <string>com.firebase.Firebase</string>
./Carthage/Build/iOS/FirebaseMessaging.framework/Info.plist:    <string>com.firebase.Firebase</string>
./Carthage/Build/iOS/GoogleToolboxForMac.framework/Info.plist:  <string>com.firebase.Firebase</string>
./Carthage/Build/iOS/nanopb.framework/Info.plist:   <string>com.firebase.Firebase</string>
./Carthage/Build/iOS/FirebaseNanoPB.framework/Info.plist:   <string>com.firebase.Firebase</string>
./Carthage/Build/iOS/FirebaseInstanceID.framework/Info.plist:   <string>com.firebase.Firebase</string>
./Carthage/Build/iOS/FirebaseCoreDiagnostics.framework/Info.plist:  <string>com.firebase.Firebase</string>

I have download the ZIP inside the JSON and all frameworks come with the same bundle-id.

Can you check?

paulocoutinhox commented 6 years ago

Hi @olejnjak and @paulb777,

I solved it changing manually all info.plist as i sad and it is working now:

./Carthage/Build/iOS/Protobuf.framework/Info.plist: <string>com.firebase.Firebase.Protobuf</string>
./Carthage/Build/iOS/Firebase.framework/Info.plist: <string>com.firebase.Firebase</string>
./Carthage/Build/iOS/FirebaseCore.framework/Info.plist: <string>com.firebase.Firebase.Core</string>
./Carthage/Build/iOS/FirebaseAnalytics.framework/Info.plist:    <string>com.firebase.Firebase.Analytics</string>
./Carthage/Build/iOS/FirebaseMessaging.framework/Info.plist:    <string>com.firebase.Firebase.Messaging</string>
./Carthage/Build/iOS/GoogleToolboxForMac.framework/Info.plist:  <string>com.firebase.Firebase.GTFM</string>
./Carthage/Build/iOS/nanopb.framework/Info.plist:   <string>com.firebase.Firebase.nanopb</string>
./Carthage/Build/iOS/FirebaseNanoPB.framework/Info.plist:   <string>com.firebase.FirebaseNanoPB</string>
./Carthage/Build/iOS/FirebaseInstanceID.framework/Info.plist:   <string>com.firebase.Firebase.InstanceID</string>
./Carthage/Build/iOS/FirebaseCoreDiagnostics.framework/Info.plist:  <string>com.firebase.Firebase.CoreDiagnostics</string>

Now you only need correct all the frameworks to have individual bundle-id. What i do is change to "com.firebase.Firebase + . + [Framework Name]"

karlpuusepp commented 6 years ago

@prsolucoes these are static frameworks, you are not supposed to add them to the copy-frameworks script

paulocoutinhox commented 6 years ago

Hi,

So, i dont need add anyone too copy-framework?

image

Thanks.

paulb777 commented 6 years ago

Right - the Firebase frameworks are all static and linked at build time and don't need to be copied for runtime linking.

paulocoutinhox commented 6 years ago

Hi,

I have updated everything and all is working.

I change all the project and make a sample that receive a message from Firebase console and show a push message. It is nice. With carthage support and makefile to help users.

Thanks for all support guys. Here is the repository:

https://github.com/prsolucoes/firebase

mortenbekditlevsen commented 6 years ago

Hi there, I have a question about the Carthage support help page.

Under Static Frameworks it is stated that: "Note that the Firebase frameworks in the distribution include static libraries. While it is fine to link these into apps, it will generally not work to depend on them from wrapper dynamic frameworks."

Could this comment be elaborated? Is it a generic logical issue with static libs inside dynamic frameworks? Is it an issue with how Carthage does this? Or is it an issue with the libraries themselves?

We are already manually building a dynamic wrapper framework using CocoaPods - and use this dynamic framework in our own Carthage setup.

Initial tests show that using this Carthage repo instead (still linking into a dynamic framework that contains all of our networking/sync logic) appears to work just fine, so it would be great to know what the issue might be.

Carthage support is a great update, thanks! Looking forward to the tvOS and macOS builds to become available through this channel as well. ;-)

paulb777 commented 6 years ago

@mortenbekditlevsen Thanks for the feedback!

Yes - it's a general issue about how static and dynamic linking works. Static linking happens at build time. Dynamic linking happens at run time. if a dynamic library depends upon a static library, that static library will be loaded at runtime, which it isn't necessarily built to do. When a second dynamic library is linked that depends on the same static library, two copies of the static library will get linked into the app.

While app's like this may pass simple tests, they will have subtle failures based on indeterministic behavior of data inside the static library - like values of static/global variables or calls to isKindOfClass:.

Xcode will log in the console One of the two will be used. Which one is undefined.

While it may be possible to make workarounds viable for particular use cases, none of Xcode, CocoaPods, or Carthage have a general purpose solution for depending on static libraries from dynamic frameworks.

tbaranes commented 6 years ago

Just wanted to say that I just migrated from solheim library to use firebase with Carthage to that new implementation and it's working perfectly! It's an awesome news 🎉

mortenbekditlevsen commented 6 years ago

Thanks, @paulb777 ,

So am I correct in assuming, that if only one dynamic library has the static libraries linked, then you will only ever have one copy of the static libraries loaded, and you will get no inderterminism in that regard?

morganchen12 commented 6 years ago

@mortenbekditlevsen that's correct.

olejnjak commented 6 years ago

I was also wondering, since Crashlytics are now part of Firebase and are the default crash reporting tool, can we expect official Carthage support? I mean different than "some guys" repo (https://github.com/Carthage/Carthage/issues/2036)?

schlingding commented 6 years ago

+1 for Fabric/Crashlytics inclusion.

TKBurner commented 6 years ago

Todd from Crashlytics here. Right now we don't have plans for official Carthage support, we will continue to support Cocoapods and static frameworks.

I'll let the team know you are interested 👍

schlingding commented 6 years ago

tmspzz commented 6 years ago

Hello,

This PR which just landed in Carthage/master makes it possible to use the archive at https://kit-downloads.fabric.io/cocoapods/fabric/1.7.6/fabric.zip with Carthage. If you want to try it yourself, run brew update carthage --HEAD

What is left to do, is for Google/Crashlytics to host the binary dependency file somewhere. This is a simple JSON, see https://github.com/Carthage/Carthage/blob/master/Documentation/Artifacts.md#binary-project-specification

@TKBurner Do you think this is something that Fabic users can expect? It would definitely be better for developers to get Fabric from the original source rather than from (so far benevolent) third parties.

EDIT: Carthage also supports local binary definitions. You can host your own locally like so:

binary "Fabric.json" ~> 1.7.6

EDIT2: this is supported starting from carthage 0.30.1

m-toyoda commented 6 years ago

+1

erikkerber commented 6 years ago

@TKBurner Does you mean that we can't expect Crashlytics.framework and Fabric.framework to support Carthage, but FirebaseXXXX.framework and all Firebase originals will have Carthage support?

miguelrc86 commented 6 years ago

Hi everyone!

I've being trying to make FirebaseDatabase work with no success... I followed the installation guide throughfully, adding ObjC to other linker flags, removing the Firebase.framework from the linked frameworks, including GoogleService-Info.plist in my build target and my subset for the Cartfile is as follows:

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

I'm receiving a lot of Apple Mach-O Linker errors... 😕 This is a new project using Xcode 9.3, iOS 11 support, Swift 4.1 any clues? Thanks in advance!

screen shot 2018-05-09 at 22 56 36

paulb777 commented 6 years ago

@miguelrc86 Occasionally, Xcode's automatic linking fails to pull in all of the necessary libraries. You can find the missing libraries by internet searching the missing symbol errors or systematically adding in all of the libraries that show up in Carthage/Build/iOS/*/Modules/module.modulemap.

In this case, the c++ and sqlite libraries need to be added to the Link Binary With Libraries Build Phase:

screen shot 2018-05-09 at 9 14 51 pm

miguelrc86 commented 6 years ago

Oh! Thank you so much @paulb777 for your ultra quick and clear response, will do that! 🙂

pisarm commented 6 years ago

This also helped me - I was missing libicucore.tbd and libc++.tbd.

miguelrc86 commented 6 years ago

Thanks @paulb777 @pisarm added those libraries, also had to include StoreKit and voila! Firebase is up and running now 👊🏻

TKBurner commented 6 years ago

You are all in great hands with @paulb777, we had a chance to meet and are trying to see what we can as far as Crashlytics.

jemartti commented 6 years ago

I've got Carthage working and running—however, I'm seeing the same linker warning as @rerelease and @Drusy:

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

There was a mention of removing any import Firebase statements; however, that seems to contradict the required step of configuring a FirebaseApp shared instance (e.g. FirebaseApp.configure() in application:didFinishLaunchingWithOptions:).

Has anyone managed to get rid of this warning?

miguelrc86 commented 6 years ago

@jemartti I resolved this by using import FirebaseCore instead if I remember well, so yeap, you need to follow the instructions by removing the Firebase framework and its related imports, hope it helps.

jemartti commented 6 years ago

Ah yes, switching from import Firebase to import FirebaseCore and adding StoreKit to "Link Binary With Libraries" got me to a clean build. Thanks @miguelrc86!

nidegen commented 6 years ago

I often get an error when running carthage update with the framework protobuf. No idea where it comes from. Happens on different machines. Any ideas? thanks:)

carthage update --platform iOS
*** Downloading binary-only framework FirebaseDynamicLinksBinary at "https://dl.google.com/dl/firebase/ios/carthage/FirebaseDynamicLinksBinary.json"
*** Downloading binary-only framework FirebasePerformanceBinary at "https://dl.google.com/dl/firebase/ios/carthage/FirebasePerformanceBinary.json"
*** Downloading binary-only framework FirebaseABTestingBinary at "https://dl.google.com/dl/firebase/ios/carthage/FirebaseABTestingBinary.json"
*** Downloading binary-only framework FirebaseFunctionsBinary at "https://dl.google.com/dl/firebase/ios/carthage/FirebaseFunctionsBinary.json"
*** Downloading binary-only framework Fabric at "https://raw.githubusercontent.com/Building42/Specs/master/Carthage/Fabric.json"
*** Downloading binary-only framework FirebaseDatabaseBinary at "https://dl.google.com/dl/firebase/ios/carthage/FirebaseDatabaseBinary.json"
*** Downloading binary-only framework FirebaseMessagingBinary at "https://dl.google.com/dl/firebase/ios/carthage/FirebaseMessagingBinary.json"
*** Downloading binary-only framework FirebaseAnalyticsBinary at "https://dl.google.com/dl/firebase/ios/carthage/FirebaseAnalyticsBinary.json"
*** Fetching Localize-Swift
*** Downloading binary-only framework FirebaseFirestoreBinary at "https://dl.google.com/dl/firebase/ios/carthage/FirebaseFirestoreBinary.json"
*** Downloading binary-only framework FirebaseAdMobBinary at "https://dl.google.com/dl/firebase/ios/carthage/FirebaseAdMobBinary.json"
*** Downloading binary-only framework FirebaseAuthBinary at "https://dl.google.com/dl/firebase/ios/carthage/FirebaseAuthBinary.json"
*** Downloading binary-only framework Crashlytics at "https://raw.githubusercontent.com/Building42/Specs/master/Carthage/Crashlytics.json"
*** Downloading binary-only framework FirebaseRemoteConfigBinary at "https://dl.google.com/dl/firebase/ios/carthage/FirebaseRemoteConfigBinary.json"
*** Downloading binary-only framework FirebaseStorageBinary at "https://dl.google.com/dl/firebase/ios/carthage/FirebaseStorageBinary.json"
*** Downloading binary-only framework FirebaseInvitesBinary at "https://dl.google.com/dl/firebase/ios/carthage/FirebaseInvitesBinary.json"
*** Checking out Localize-Swift at "2.0.0"
*** Downloading binary-only framework Crashlytics at "https://raw.githubusercontent.com/Building42/Specs/master/Carthage/Crashlytics.json"
*** Downloading binary-only framework Fabric at "https://raw.githubusercontent.com/Building42/Specs/master/Carthage/Fabric.json"
*** xcodebuild output can be found in /var/folders/xw/40bn71nx71591_rwtsp05k780000gn/T/carthage-xcodebuild.3BRGy2.log
*** Downloading binary-only framework FirebaseABTestingBinary at "https://dl.google.com/dl/firebase/ios/carthage/FirebaseABTestingBinary.json"
*** Downloading binary-only framework FirebaseAdMobBinary at "https://dl.google.com/dl/firebase/ios/carthage/FirebaseAdMobBinary.json"
*** Downloading binary-only framework FirebaseAnalyticsBinary at "https://dl.google.com/dl/firebase/ios/carthage/FirebaseAnalyticsBinary.json"
*** Downloading binary-only framework FirebaseAuthBinary at "https://dl.google.com/dl/firebase/ios/carthage/FirebaseAuthBinary.json"
*** Downloading binary-only framework FirebaseDatabaseBinary at "https://dl.google.com/dl/firebase/ios/carthage/FirebaseDatabaseBinary.json"
*** Downloading binary-only framework FirebaseDynamicLinksBinary at "https://dl.google.com/dl/firebase/ios/carthage/FirebaseDynamicLinksBinary.json"
*** Downloading binary-only framework FirebaseFirestoreBinary at "https://dl.google.com/dl/firebase/ios/carthage/FirebaseFirestoreBinary.json"
*** Downloading binary-only framework FirebaseFunctionsBinary at "https://dl.google.com/dl/firebase/ios/carthage/FirebaseFunctionsBinary.json"
*** Downloading binary-only framework FirebaseInvitesBinary at "https://dl.google.com/dl/firebase/ios/carthage/FirebaseInvitesBinary.json"
*** Downloading binary-only framework FirebaseMessagingBinary at "https://dl.google.com/dl/firebase/ios/carthage/FirebaseMessagingBinary.json"
*** Downloading binary-only framework FirebasePerformanceBinary at "https://dl.google.com/dl/firebase/ios/carthage/FirebasePerformanceBinary.json"
*** Downloading binary-only framework FirebaseRemoteConfigBinary at "https://dl.google.com/dl/firebase/ios/carthage/FirebaseRemoteConfigBinary.json"
A shell task (/usr/bin/xcrun dwarfdump --uuid /Users/<...>/Carthage/Build/iOS/Protobuf.framework/Protobuf) failed with exit code 1:
error: unable to open '/Users/<...>/Carthage/Build/iOS/Protobuf.framework/Protobuf': No such file or directory
paulb777 commented 6 years ago

@nidegen I've seen this a few times, but not able to reproduce reliably. I suspect a Carthage race condition since Protobuf.framework is a dependency of multiple components.

Rerunning the carthage update command is a workaround.

nidegen commented 6 years ago

@paulb777 yes I have also just reupdated carthage a couple of times, but it is really a mess for our CI pipelines😬😬

are the binaries not just download only? how comes carthage has to check out dependencies there?

paulb777 commented 6 years ago

@nidegen Since Carthage doesn't do dependencies for binaries, the multiple Firebase components that depend on Protobuf.framework need to include it.

schlingding commented 6 years ago

Some frameworks are fetching version 5.0.1 and some version 5.1.0.

binary "https://dl.google.com/dl/firebase/ios/carthage/FirebaseAnalyticsBinary.json"
binary "https://dl.google.com/dl/firebase/ios/carthage/FirebaseMessagingBinary.json"
binary "https://dl.google.com/dl/firebase/ios/carthage/FirebasePerformanceBinary.json"
binary "https://dl.google.com/dl/firebase/ios/carthage/FirebaseRemoteConfigBinary.json"
*** Downloading binary-only framework FirebaseAnalyticsBinary at "https://dl.google.com/dl/firebase/ios/carthage/FirebaseAnalyticsBinary.json"
*** Downloading FirebaseAnalyticsBinary.framework binary at "5.0.1"
*** Downloading binary-only framework FirebaseMessagingBinary at "https://dl.google.com/dl/firebase/ios/carthage/FirebaseMessagingBinary.json"
*** Downloading FirebaseMessagingBinary.framework binary at "5.1.0"
*** Downloading binary-only framework FirebasePerformanceBinary at "https://dl.google.com/dl/firebase/ios/carthage/FirebasePerformanceBinary.json"
*** Downloading FirebasePerformanceBinary.framework binary at "5.0.1"
*** Downloading binary-only framework FirebaseRemoteConfigBinary at "https://dl.google.com/dl/firebase/ios/carthage/FirebaseRemoteConfigBinary.json"
*** Downloading FirebaseRemoteConfigBinary.framework binary at "5.0.1"
binary "https://dl.google.com/dl/firebase/ios/carthage/FirebasePerformanceBinary.json" == 5.1.0

produces

No available version for binary "https://dl.google.com/dl/firebase/ios/carthage/FirebasePerformanceBinary.json" satisfies the requirement: == 5.1.0

Anyone else seeing this issue?

nidegen commented 6 years ago

@paulb777 i dont get it. if binaries have no dependencies (I already understood it that way) why is there an issue with a dependency (protobuf). To me it seems that carthage does check for dependencies after all, or performs some kind of processing of the binaries. i dont see why it should / a binary package is performing anything

paulb777 commented 6 years ago

@nidegen The Carthage zip files for multiple Firebase components include the Protobuf.framework. If you're using two or more of those components, Carthage will attempt to do multiple copies to ./Carthage/Build/iOS/Protobuf.framework.

@schlingding Does clearing the Carthage cache make a difference - rm -rf ~/Library/Caches/org.carthage.CarthageKit

schlingding commented 6 years ago

@paulb777 I have tried clearing the cache and removing the Carthage folder as well. Same results. I’m on the latest version of Carthage.

Are you getting 5.1.0 when running Carthage? If so I’ll debug further.

schlingding commented 6 years ago

@paulb777 Ran Carthage today and now it's pulling all 5.1.0 versions. Leaving the previous comment intact in case someone else runs into the issue.

walsht commented 6 years ago

Seeing this on "5.2.0"

Failed to write to /.../Carthage/Build/iOS/Protobuf.framework: Error Domain=NSCocoaErrorDomain Code=513 "“Protobuf.framework” couldn’t be removed because you don’t have permission to access it." UserInfo={NSFilePath=/.../Carthage/Build/iOS/Protobuf.framework, NSUserStringVariant=(
    Remove
), NSUnderlyingError=0x7faa64d60730 {Error Domain=NSPOSIXErrorDomain Code=66 "Directory not empty"}}

Only way to resolve is binary "https://dl.google.com/dl/firebase/ios/carthage/FirebasePerformanceBinary.json" == 5.1.0

nidegen commented 6 years ago

@paulb777 For the protobuf checkout bug, deleting cache with rm -rf ~/Library/Caches/org.carthage.CarthageKit actually fixes my issue, probably also yours @walsht

I run it before each carthage update

yoiang commented 6 years ago

I also had to manually add SystemConfiguration.framework when I was Carthage-ing Firebase Analytics, otherwise it was complaining about missing a number of SC symbols

tbaranes commented 6 years ago

Hey guys! Can you add macOS support? The binary binary ".../firebase/ios/carthage/FirebaseAnalyticsBinary.json" is working perfectly for iOS, but it would even greater to have a binary link for macOS as well.

josemssilva commented 6 years ago

Anyone had troubles updating from 5.4 to 5.6? Missing FirebaseNanoPB and GoogleToolboxForMac, and I'm unable to build the project without those.

paulb777 commented 6 years ago

See #1701 for discussion of carthage update from a release before Firebase 5.5.0 to one after it.

schlingding commented 5 years ago

Firebase is releasing weeks faster than the updates to the binary files for carthage.

At the time of this post, I'm seeing the latest carthage binary references at 5.8.0 where 5.8.1, 5.9.0, and 5.10.0 have since been released.

Can updating these binary references be part of the Firebase iOS release process or are there further issues?

Please update soon so the community can take advantage of the bug fixes and enhancements.

Thank you!

paulb777 commented 5 years ago

@schlingding 5.10.0 is now available via Carthage.

See #1862 to follow the status of official Carthage support

paulb777 commented 5 years ago

Those of you interested in Firebase via Carthage may want to check out Firebase via Rome. Rome provides many of the Carthage features as well as a few additional advantages. Check out the details at https://github.com/firebase/firebase-ios-sdk/blob/master/Rome.md.

We'd love to hear any feedback in another issue.

paulb777 commented 5 years ago

Closing since Carthage is now available experimentally. We'll track making it officially supported in #1862.