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

Unable to install FirebaseAnalytics Xcode 12 with SPM #6360

Closed ghost closed 4 years ago

ghost commented 4 years ago

[REQUIRED] Step 1: Describe your environment

[REQUIRED] Step 2: Describe the problem

Hi, I try to install FirebaseAnalytics from the SPM, and after compiling an error appears and the application doesn't install. I specify that the problem appears when I try to install FirebaseAnalytics. No problems with FirebaseCrashlytics and Firebase. The -ObjC flag is well added.

Screenshot 2020-08-28 at 15 28 53 Screenshot 2020-08-28 at 15 28 58 Screenshot 2020-08-28 at 15 29 10 Screenshot 2020-08-28 at 15 29 17
google-oss-bot commented 4 years ago

I found a few problems with this issue:

ryanwilson commented 4 years ago

Hey @coulonb - sorry for the issues you're seeing.

I'm unable to reproduce this on both device and simulator. Can you please try creating a brand new project, following the installation steps and seeing if you still run into the issue? Also, is this an iOS/iPadOS app, or does it target a different platform?

It could be a provisioning issue as well. We'll likely need a repro to make any further progress on it. Thanks!

ryanwilson commented 4 years ago

Thanks for the extra info @EthanHannah.

@coulonb can you follow the same steps to see if that helps for you? Restarting, cleaning the build folder, and reinstalling the app?

If that doesn't help you, we'll likely need a project or steps to reproduce the issue in order to make further progress. Hopefully that helps get you unblocked, though!

Neilfau commented 4 years ago

I also have the same issue, I have Firebase Analytics as a dependency of another package that is added to my main project. I get the following error when I try to run the app on device or simulator and ive tried all the Xcode tricks with derived data, restarting devices etc.

Details

Unable to install "FirebaseExample"
Domain: com.apple.dt.MobileDeviceErrorDomain
Code: -402653103
--
Could not inspect the application package.
Domain: com.apple.dt.MobileDeviceErrorDomain
Code: -402653103
User Info: {
    DVTRadarComponentKey = 282703;
    MobileDeviceErrorCode = "(0xE8000051)";
    "com.apple.dtdevicekit.stacktrace" = (
    0   DTDeviceKitBase                     0x000000012b9b290f DTDKCreateNSErrorFromAMDErrorCode + 220
    1   DTDeviceKitBase                     0x000000012b9f10f4 __90-[DTDKMobileDeviceToken installApplicationBundleAtPath:withOptions:andError:withCallback:]_block_invoke + 155
    2   DVTFoundation                       0x000000010e93dcef DVTInvokeWithStrongOwnership + 71
    3   DTDeviceKitBase                     0x000000012b9f0e35 -[DTDKMobileDeviceToken installApplicationBundleAtPath:withOptions:andError:withCallback:] + 1440
    4   IDEiOSSupportCore                   0x000000012b861d84 __118-[DVTiOSDevice(DVTiPhoneApplicationInstallation) processAppInstallSet:appUninstallSet:installOptions:completionBlock:]_block_invoke.292 + 3513
    5   DVTFoundation                       0x000000010ea6c45a __DVT_CALLING_CLIENT_BLOCK__ + 7
    6   DVTFoundation                       0x000000010ea6e07c __DVTDispatchAsync_block_invoke + 1191
    7   libdispatch.dylib                   0x00007fff72f3a6c4 _dispatch_call_block_and_release + 12
    8   libdispatch.dylib                   0x00007fff72f3b658 _dispatch_client_callout + 8
    9   libdispatch.dylib                   0x00007fff72f40c44 _dispatch_lane_serial_drain + 597
    10  libdispatch.dylib                   0x00007fff72f415d6 _dispatch_lane_invoke + 363
    11  libdispatch.dylib                   0x00007fff72f4ac09 _dispatch_workloop_worker_thread + 596
    12  libsystem_pthread.dylib             0x00007fff73195a3d _pthread_wqthread + 290
    13  libsystem_pthread.dylib             0x00007fff73194b77 start_wqthread + 15
);
}
--

System Information

macOS Version 10.15.6 (Build 19G2021)
Xcode 12.0 (17210.1)
ryanwilson commented 4 years ago

@Neilfau sorry for the troubles. Are you able to reproduce it by creating a blank project and adding the dependency there? If it does, please let us know what steps you took so we can reproduce it. Without being able to reproduce it on our end we likely won't be able to help much more. Thanks!

Neilfau commented 4 years ago

@ryanwilson with a blank project the app runs but crashes shortly after starting. All I call is FirebaseApp.configure() but nothing else. I get the error: -[__NSCFString apm_UTF32Length]: unrecognized selector sent to instance 0x280267dc0

Neilfau commented 4 years ago

@ryanwilson to clarify though that was a blank project with a local swift package dragged into the project with firebase as a dependency of that. Im now going to just add firebase as a dependency of the blank project and check that works.

ryanwilson commented 4 years ago

Thanks @Neilfau - the crashing issue sounds like you need to add the -ObjC linker option.

Neilfau commented 4 years ago

@ryanwilson ah yeah good point forgot to add that for the blank project. Will try again.

Neilfau commented 4 years ago

@ryanwilson ok can confirm it works if Firebase is a dependency of a local package and if added to a blank project locally by dragging the package into Xcode and also if the firebase package is added to project directly. I have also added the package with the firebase dependency remotely and it also works fine, so I think the error is possibly related to having a project with 2 different packages that both have firebase as a dependency?

ryanwilson commented 4 years ago

Ah, so you're saying your setup has dependency Foo which depends on Firebase, and dependency Bar which also depends on Firebase, and you think they're both being included? At first thought that shouldn't be happening since Swift Package Manager's dependency resolution should catch that, but also the error would be a duplicate symbols error instead of the above error.

Can you reproduce the above error with that setup?

Neilfau commented 4 years ago

@ryanwilson not sure if I explained that well enough but my app structure is as follows:

Package A - dependencies: Firebase Package (FirebaseCore, FirebaseDatabase) & Package B Package B - dependencies: Firebase Package (FirebaseAnalytics)

Xcode Project - dependencies: Package A

ryanwilson commented 4 years ago

@Neilfau makes sense, thanks. If you add those dependencies in the blank project (if possible), does the error happen for you still?

Neilfau commented 4 years ago

@ryanwilson ive added firebase package (FirebaseCore, FirebaseDatabase) to the blank project and have also added the test package which has firebase (FirebaseAnayltics, FirebaseCore) as dependency also and the project builds and runs fine. The next thing im going to try is making a second package with a firebase dependency and adding both packages to the blank project and see what happens.

ghost commented 4 years ago

@ryanwilson @EthanHannah Restarting, clean everything seems to be not the solution for me. I will tried with a new starter project and back to you.

Neilfau commented 4 years ago

@ryanwilson Ok I completely recreated the same structure with a blank project and it works on both device and simulator so I'm no closer to finding the cause of the issue unfortunately. In my actual project I get this additional error when trying to run on a simulator compared to running on my device:

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/neil/Library/Developer/CoreSimulator/Devices/35051889-6FBE-4376-92CF-51DEE6706D23/data/Library/Caches/com.apple.mobile.installd.staging/temp.qkBgi4/extracted/SportPointExampleLocal.app/Frameworks/GoogleAppMeasurement.framework; Extra info about Info.plist: Couldn't stat /Users/neil/Library/Developer/CoreSimulator/Devices/35051889-6FBE-4376-92CF-51DEE6706D23/data/Library/Caches/com.apple.mobile.installd.staging/temp.qkBgi4/extracted/SportPointExampleLocal.app/Frameworks/GoogleAppMeasurement.framework/Info.plist: No such file or directory
--
Failed to load Info.plist from bundle at path /Users/neil/Library/Developer/CoreSimulator/Devices/35051889-6FBE-4376-92CF-51DEE6706D23/data/Library/Caches/com.apple.mobile.installd.staging/temp.qkBgi4/extracted/SportPointExampleLocal.app/Frameworks/GoogleAppMeasurement.framework; Extra info about Info.plist: Couldn't stat /Users/neil/Library/Developer/CoreSimulator/Devices/35051889-6FBE-4376-92CF-51DEE6706D23/data/Library/Caches/com.apple.mobile.installd.staging/temp.qkBgi4/extracted/SportPointExampleLocal.app/Frameworks/GoogleAppMeasurement.framework/Info.plist: No such file or directory
Domain: MIInstallerErrorDomain
Code: 35
User Info: {
    FunctionName = "-[MIBundle _validateWithError:]";
    LegacyErrorString = PackageInspectionFailed;
    SourceFileLine = 131;
}
--

System Information

macOS Version 10.15.6 (Build 19G2021)
Xcode 12.0 (17210.1)
ghost commented 4 years ago

Like @Neilfau, after created new project with exactly the same structures (same lib, versioning flag,..) I don't have the problem on the new project. I don't understand where the problem on the initial project may come from.

Neilfau commented 4 years ago

@ryanwilson think I've tried everything now & I still cannot recreate the issue with a blank project. I have now instead of adding the package that has the firebase analytics as a dependency to my second package, I have just added the firebase analytics to the target dependencies of the second package and im hoping that builds and runs. So for now I'll have use Analytics framework directly rather than having a separate package for it which I didn't really want to do but I'm running out time to spend on this issue. Hopefully someone else can do some more digging and find the cause.

Neilfau commented 4 years ago

@ryanwilson unfortunately that didn't work either ... soon as I add the target dependency: .product(name: "FirebaseAnalytics", package: "Firebase") I get the error when trying to run the app, if I comment it out it runs again.

jesusmateos1234 commented 4 years ago

The problem with GoogleAppMeasurement.plist also it's reproduced with Carthage

ghost commented 4 years ago

Same issue concerning the simulator but it's not totally the same errorr. I thought maybe there was a cache conflict with cocoapods because I had installed FirebaseAnalytics before with this pod. Everything is clean and cached, Pods are completely remove from the project so it's a possibility that has been ruled out.

Details

This app was unable to be installed.
Domain: IXUserPresentableErrorDomain
Code: 2
--
Failed to load Info.plist from bundle at path /Users/pierrickcoulon-safeware/Library/Developer/CoreSimulator/Devices/4216D79A-92A0-4F3E-8C07-0B42FD6034CA/data/Library/Caches/com.apple.mobile.installd.staging/temp.S30IwG/extracted/Hamilton Visitor.app/Frameworks/GoogleAppMeasurement.framework
Domain: MIInstallerErrorDomain
Code: 35
User Info: {
    FunctionName = "-[MIBundle _validateWithError:]";
    LegacyErrorString = PackageInspectionFailed;
    SourceFileLine = 38;
}
--

System Information

macOS Version 10.15.6 (Build 19G73)
Xcode 12.0 (17210.1)
paulb777 commented 4 years ago

@Neilfau @coulonb Is there anything different about Build Settings between the new project and the project that demonstrates the issue?

Are you able to incrementally add to the new project or remove from the broken project to isolate what triggers the problem?

If anyone can share a reproducible example, it would be helpful.

ghost commented 4 years ago

@paulb777 I looked carefully line by line and I saw nothing that changes in the build settings. I'm trying to recreate the bug on a new project but for the moment impossible to reproduce. And to get the things that trigger the problem in the broken project I would have to know what's going on too. I'm still looking...

Neilfau commented 4 years ago

@paulb777 I couldn't see anything in the build settings and ive tried adding other packages incrementally but not class files as its a big project and would take me a long time and don't think that would have anything to do with it anyway and I have only one class that imports FirebaseDatabase and one class for analytics.

paulb777 commented 4 years ago

Thanks for checking @coulonb @Neilfau. Unfortunately, we're stalled on our end until we can get a reproducible example.

Neilfau commented 4 years ago

@paulb777 @ryanwilson

I have an update about this issue... I now have it kind of working. So the structure of my app is like the following:

[Firebase Package] -> [Analytics Package] -> [Core Package] -> [Xcode Project]

If the [Core Package] is added to the [Xcode Project] locally then when I try to build and run the app I get the same errors above. If however I add the package using Xcode's Add Package Dependency and use a repo url to add the package the app will build and run fine and analytics are working.

I would also add that I am now using the 6.32-spm-beta branch and I had to remove the following from my package file because it caused the package to fail:

 .product(name: "Firebase", package: "Firebase"),
 .product(name: "FirebaseCore", package: "Firebase"),

Hope this might help point you in the right direction.

kylebrowning commented 4 years ago

Yup, this is happening for me too. I don't have a dependency setup like the above.

Im straight up depending on firebase-ios-sdk and I am including.

image

Removing firebase analytics solves the issue, but that's kind of a nonstarter considering we use it.

goncharik commented 4 years ago

Hello @paulb777

I have the same issue. And I was able to reproduce it with new project. Was doing nothing special, just created new xcode project. Set it up with deployment target for iOS 12 and just add few swift packages with Firebase. And it shows same error about missing Info.plist on running for simulator. You can checkout this demo project here: https://github.com/goncharik/XCFrameworkSPMDemo

Please advice what am I doing wrong.

ryanwilson commented 4 years ago

Aha, thanks for the project @goncharik! I now see the issue with the project you provided. Digging into it now to see if I can track this down.

I thought this may have been an project that targets iOS < 13 issue but after creating a new project and modifying it appropriately to run on iOS 10, adding Firebase to it via SwiftPM, I was still unable to reproduce the issue.

@Neilfau re: removing the Firebase and FirebaseCore products - that was an intention decision we made since those should be included by default in every installation and it's likely just confusing for future users. Thanks for bringing that up though!

Neilfau commented 4 years ago

@ryanwilson ok great! Yeah my project targets iOS 13.0+ so I don't think its that.

kylebrowning commented 4 years ago

My project is also 13+

paulb777 commented 4 years ago

Thanks for the repro case @goncharik ! We were able to isolate and fix.

To pick up the fix - File -> Swift Packages -> Update to Latest Package Versions

We were able to isolate to missing Info.plist files in the Analytics .frameworks and fix in #6444. It's a mystery about why this sometimes works and sometimes doesn't. Perhaps an Xcode race condition?