firebase / firebase-ios-sdk

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

Not able to run app in simulator due to framework identifier duplication in Info.plist #5299

Closed gbejarano01 closed 4 years ago

gbejarano01 commented 4 years ago

Environment

The problem

Steps to reproduce:

After upgrading to the latest version of Firebase and after adding additional frameworks based on research as in the doc is not clear what to do the app compiles just fine, but when trying to run it I get this:

Screen Shot 2020-04-06 at 5 07 05 PM

It seems like the GTMAppAuth.framework and abseil.framework frameworks are both sharing the same app id in the Info.plist

However I'm not sure if it's me doing something wrong or what.

Please see the 2 attachments below that shows the same id:

Screen Shot 2020-04-06 at 5 12 29 PM Screen Shot 2020-04-06 at 5 12 05 PM

Thank you!

morganchen12 commented 4 years ago

Are you able to work around this by changing one of the frameworks' bundle identifiers to something else?

By default, neither of those frameworks should have the bundle ID com.firebase.Firebase. Something strange must be going on in the dependency installation process. @paulb777 do you know of anything in CocoaPods that could cause this?

gbejarano01 commented 4 years ago

just tried now @morganchen12 but I'm getting another issue, I think unrelated to this. I'll keep you updated. Thanks!

gbejarano01 commented 4 years ago

@morganchen12 I modified the bundle ID manually and I fixed the other issue I had (not related to Firebase) and now I'm getting this:

2020-04-06 17:43:59.601651-0400 project1819[49437:30859439] -[FIRInstallationsItem registeredInstallationWithJSONData:date:error:]: unrecognized selector sent to instance 0x600000e83ec0 2020-04-06 17:43:59.614022-0400 project1819[49437:30859439] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[FIRInstallationsItem registeredInstallationWithJSONData:date:error:]: unrecognized selector sent to instance 0x600000e83ec0' *** First throw call stack: ( 0 CoreFoundation 0x00007fff23e3dcce __exceptionPreprocess + 350 1 libobjc.A.dylib 0x00007fff50b3b9b2 objc_exception_throw + 48 2 CoreFoundation 0x00007fff23e5e9f4 -[NSObject(NSObject) doesNotRecognizeSelector:] + 132 3 CoreFoundation 0x00007fff23e426cc ___forwarding___ + 1436 4 CoreFoundation 0x00007fff23e449b8 _CF_forwarding_prep_0 + 120 5 project1819 0x0000000103bdaf4c __84-[FIRInstallationsAPIService registeredInstallationWithInstallation:serverResponse:]_block_invoke + 240 6 FBLPromises 0x000000010629ac12 __38+[FBLPromise(DoAdditions) onQueue:do:]_block_invoke + 27 7 libdispatch.dylib 0x0000000107234f11 _dispatch_call_block_and_release + 12 8 libdispatch.dylib 0x0000000107235e8e _dispatch_client_callout + 8 9 libdispatch.dylib 0x0000000107243e67 _dispatch_main_queue_callback_4CF + 1357 10 CoreFoundation 0x00007fff23da1849 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9 11 CoreFoundation 0x00007fff23d9c399 __CFRunLoopRun + 2041 12 CoreFoundation 0x00007fff23d9b884 CFRunLoopRunSpecific + 404 13 GraphicsServices 0x00007fff38b5ac1a GSEventRunModal + 139 14 UIKitCore 0x00007fff48c19220 UIApplicationMain + 1605 15 project1819 0x00000001034ba49b main + 75 16 libdyld.dylib 0x00007fff519b910d start + 1 17 ??? 0x0000000000000002 0x0 + 2 )

Which is weird, it looks like some lib is not finding the right methods or so...

I'm following this other ticket cause it's addressing the same issue but I can't quite seem to find that helpful as I'm not using cocoapods: https://github.com/firebase/firebase-ios-sdk/issues/4711

morganchen12 commented 4 years ago

That method is defined in a category, so you're likely missing the -ObjC linker flag.

gbejarano01 commented 4 years ago

Thanks @morganchen12, is this what you mean? It's set correctly and still not working if so:

Screen Shot 2020-04-06 at 6 02 12 PM
paulb777 commented 4 years ago

The Firebase Carthage frameworks should be linked at build time and not installed at load time.

Make sure this step in the Carthage README is followed:

Please note that you shouldn't add any of the Firebase frameworks to the Carthage build phase (copy-frameworks). The frameworks contain static libraries that are linked at build time.

gbejarano01 commented 4 years ago

Thanks @paulb777 I just tried the whole configuration again, and I'm still getting the unrecognized selector issue

Also, remember I had to rename the bundle id so this can work.

Not sure what else to try.

paulb777 commented 4 years ago

The most likely cause for both problems is lingering references in the Xcode project. Make sure that there are no Firebase references left before starting the configuration.

ryanwilson commented 4 years ago

Re: bundle IDs, I think #5302 should address it.

gbejarano01 commented 4 years ago

Thanks everyone for helping, I deleted everything and re-added all the libraries, now I'm getting another issue related to another info plist when trying to run it, all builds ok

Screen Shot 2020-04-07 at 2 00 25 PM

Details

This app could not be installed at this time. Domain: IXUserPresentableErrorDomain Code: 1 Failure Reason: Could not install at this time. Recovery Suggestion: Failed to load Info.plist from bundle at path /Users/user/Library/Developer/CoreSimulator/Devices/5D70DC5C-613F-40C2-A963-DE324243E051/data/Library/Caches/com.apple.mobile.installd.staging/temp.KiaLDG/extracted/Payload/project1819.app/Frameworks/FirebaseAnalytics.framework; Extra info about plist: ACL=

Failed to load Info.plist from bundle at path /Users/user/Library/Developer/CoreSimulator/Devices/5D70DC5C-613F-40C2-A963-DE324243E051/data/Library/Caches/com.apple.mobile.installd.staging/temp.KiaLDG/extracted/Payload/project1819.app/Frameworks/FirebaseAnalytics.framework; Extra info about plist: ACL= Domain: MIInstallerErrorDomain Code: 35 User Info: { FunctionName = "-[MIBundle _validateWithError:]"; LegacyErrorString = PackageInspectionFailed; SourceFileLine = 128; } System Information

macOS Version 10.15.3 (Build 19D76) Xcode 11.4 (16134)

It looks something changed and the Info.plist is not there now:

Old Version

Screen Shot 2020-04-07 at 2 13 15 PM

New Version

Screen Shot 2020-04-07 at 2 13 06 PM
paulb777 commented 4 years ago

It looks like there is still a problem with the Xcode configuration. FirebaseAnalytics.framework should not be added into the bundle - /Users/user/Library/Developer/CoreSimulator/Devices/5D70DC5C-613F-40C2-A963-DE324243E051/data/Library/Caches/com.apple.mobile.installd.staging/temp.KiaLDG/extracted/Payload/project1819.app/Frameworks/FirebaseAnalytics.framework

gbejarano01 commented 4 years ago

@paulb777 removed now seeing this when tried running.

Screen Shot 2020-04-07 at 3 13 52 PM
paulb777 commented 4 years ago

Yep, FirebaseAnalytics still needs to be linked statically. It just shouldn't be added to the bundle. In Carthage, that typically means making sure it is not included in the copy-frameworks build phase.

gbejarano01 commented 4 years ago

Yes @paulb777 is not included in the copy-frameworks.

Maybe something that I haven't explained, we went through the initial setup while ago, we were just running Carthage to get the latest framework version, so not sure what could be wrong if we haven't changed anything in the config nor started from scratch

paulb777 commented 4 years ago

The only other thing I can think of would be something about Xcode 11.4 is causing it. However, if that were the case, I would expect to see other similar reports.

gbejarano01 commented 4 years ago

OK, thanks @paulb777 I'm still getting ld: warning: Could not find or use auto-linked library 'stdc++'

I seem not to find anything about this

morganchen12 commented 4 years ago

@gbejarano01 can you share your project?

gbejarano01 commented 4 years ago

sorry @morganchen12 I don't think I can, I can send you logs and other things if you want.

paulb777 commented 4 years ago

May need to explicitly add libc++ to the Link Binary With Libraries Buiild Phase:

Screen Shot 2020-04-07 at 3 25 34 PM

morganchen12 commented 4 years ago

Note that you can also accidentally add Carthage artifacts to your bundle if they're in the "Copy Bundle Resources" build phase.

gbejarano01 commented 4 years ago

@paulb777

Screen Shot 2020-04-07 at 6 29 49 PM

Still getting this

Screen Shot 2020-04-07 at 6 30 39 PM
gbejarano01 commented 4 years ago

Thanks @morganchen12 there is no Carthage artifact on the Copy Bundle Resources phase

paulb777 commented 4 years ago

Ah, the difference between libstdc++ and libc++.

Is there more context around the warning message describing where the reference comes from or what the undefined symbols are?

The warning may be ok with the real issue being the undefined symbols.

gbejarano01 commented 4 years ago

@paulb777 That's what I thought, but since I'm not familiar with those libraries, I was unsure.

Screen Shot 2020-04-07 at 6 39 25 PM

Please note that now it seems to be referenced from Vision Framework, but before was from a different framework, we had Vision removed, but since you suggested to follow the config from scratch now I added all the Firebase frameworks.

Still we got the same error, before from Analytics: https://github.com/firebase/firebase-ios-sdk/issues/5299#issuecomment-610571991

paulb777 commented 4 years ago

@gbejarano01 That error would come from linking FirebaseMLVision.framework without also linking GoogleAPIClientForREST.xcframework. You can find where symbols are defined and undefined with the nm utility like

 $ nm FirebaseMLVision.framework/FirebaseMLVision | grep DetectedBreak_Type_LineBreak
                 U _kGTLRVision_DetectedBreak_Type_LineBreak
                 U _kGTLRVision_DetectedBreak_Type_LineBreak
$ nm GoogleAPIClientForREST.xcframework/ios-armv7_arm64/GoogleAPIClientForREST.framework/GoogleAPIClientForREST  | grep DetectedBreak_Type_LineBreak
-------- S _kGTLRVision_DetectedBreak_Type_LineBreak
-------- S _kGTLRVision_GoogleCloudVisionV1p1beta1TextAnnotationDetectedBreak_Type_LineBreak
-------- S _kGTLRVision_GoogleCloudVisionV1p2beta1TextAnnotationDetectedBreak_Type_LineBreak
-------- S _kGTLRVision_GoogleCloudVisionV1p3beta1TextAnnotationDetectedBreak_Type_LineBreak
-------- S _kGTLRVision_GoogleCloudVisionV1p4beta1TextAnnotationDetectedBreak_Type_LineBreak
gbejarano01 commented 4 years ago

OK, @paulb777 I got it working.

I basically created an empty project and followed the configuration again, I had to do some additional things that are not described in the readme but I ended up having it working.

So then, I went into my project, removed all the references to any Firebase framework or dependencies and did exactly what I did with the empty project.

And that made it work.

Only one thing that might help others, after that configuration I got the following that basically was fixed by wiping DerivedData:


`warning: Swift error in fallback scratch context: error: :1:1: error: umbrella header for module 'FirebaseCore' does not include header 'FirebaseCore-umbrella.h'

import "Headers/FirebaseCore.h"

^

:1:9: note: in file included from :1: #import "Headers/Firebase.h" ^ error: /Users/user/GitHub/project/Carthage/Build/iOS/Firebase.framework/Headers/Firebase.h:15:9: error: could not build module 'FirebaseCore' #import ^ error: :1:1: error: umbrella header for module 'FirebaseAuth' does not include header 'FirebaseAuth-umbrella.h' #import "Headers/FirebaseAuth.h" ^ error: :1:1: error: umbrella header for module 'FirebaseDatabase' does not include header 'FirebaseDatabase-umbrella.h' #import "Headers/FirebaseDatabase.h" ^ error: :1:1: error: umbrella header for module 'FirebaseDynamicLinks' does not include header 'FirebaseDynamicLinks-umbrella.h' #import "Headers/FirebaseDynamicLinks.h" ^ error: :1:1: error: umbrella header for module 'FirebaseFirestore' does not include header 'FirebaseFirestore-umbrella.h' #import "Headers/FirebaseFirestore.h" ^ error: :1:1: error: umbrella header for module 'FirebaseFunctions' does not include header 'FirebaseFunctions-umbrella.h' #import "Headers/FirebaseFunctions.h" ^ error: :1:1: error: umbrella header for module 'FirebaseInstanceID' does not include header 'FirebaseInstanceID-umbrella.h' #import "Headers/FirebaseInstanceID.h" ^ error: :1:1: error: umbrella header for module 'FirebaseMessaging' does not include header 'FirebaseMessaging-umbrella.h' #import "Headers/FirebaseMessaging.h" ^ error: :1:1: error: umbrella header for module 'FirebaseRemoteConfig' does not include header 'FirebaseRemoteConfig-umbrella.h' #import "Headers/FirebaseRemoteConfig.h" ^ error: :1:1: error: umbrella header for module 'FirebaseStorage' does not include header 'FirebaseStorage-umbrella.h' #import "Headers/FirebaseStorage.h" ^ error: could not build Objective-C module 'Firebase' note: This error message is displayed only once. If the error displayed above is due to conflicting search paths to Clang modules in different images of the debugged executable, this can slow down debugging of Swift code significantly, since a fresh Swift context has to be created every time a conflict is encountered.` --- It sounds like this is fixed at the moment, thanks so much @paulb777 @morganchen12 for helping me on figuring it out with me. Just a quick feedback if you allow me, I think the setup guide [Carthage README](https://github.com/firebase/firebase-ios-sdk/blob/master/Carthage.md) could include more detail and be more user friendly, specifically about the links to other GitHub issues, it requires some reading and digesting to understand those points. I think also, whatever are the dependencies need to be listed by module/framework somewhere, for instance I had to add libc++.tbd, StoreKit.framework and LocalAuthentication.framework, which for a more advance user is easy to figure out the dependencies (sometimes) by looking at the logs but this would be hard for some other people. In addition and I'm not sure if I did it but it was not needed, I had to add `github "google/promises"` to the Cartfile as well. I think this only applies to Carthage users, it seems like the ones using CocoaPods are not having so much trouble with this. Anyway, thanks so much again for the good work and for helping me on this!
paulb777 commented 4 years ago

@gbejarano01 Glad you got it working! Thanks for the feedback about the instructions. We'll consider how to improve them.