Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding firebase-ios-sdk to Xcode Swift Packages, as well as depending on it in a local Swift Package causes packages to fail to resolve consistently. #7363

Closed
jondwillis opened this issue Jan 23, 2021 · 6 comments

Comments

@jondwillis
Copy link

jondwillis commented Jan 23, 2021

[REQUIRED] Step 1: Describe your environment

  • Xcode version: 12.3
  • Firebase SDK version: 7.4.0 (also affects at least 7.3.x)
  • Installation method: Swift Package Manager
  • Firebase Component: Analytics, FirebaseCrashlytics, perhaps all.

[REQUIRED] Step 2: Describe the problem

Steps to reproduce:

(See example project linked at the bottom)

adding firebase-ios-sdk to Xcode Swift Packages, as well as depending on it in a local Swift Package causes packages to fail to resolve consistently.

The Results:

firebase-ios-sdk displays as greyed out
the underlying error

artifact of binary target 'FirebaseAnalytics' failed extraction: The operation couldn’t be completed. (TSCBasic.StringError error 1.)
artifact of binary target 'GoogleAppMeasurement' failed extraction: The operation couldn’t be completed. (TSCBasic.StringError error 1.)

The (Workaround) Solution:

Some combination of closing Xcode, Resetting Package Cache, and Updating Package Dependencies can resolve it temporarily.

Relevant Code:

https://github.com/jondwillis/FirebaseSPMBug

@paulb777
Copy link
Member

Thanks for the report.

It's almost certainly a Swift Package Manager bug and I recommend reporting there also. It looks similar to https://forums.swift.org/t/problem-in-xcode-project-to-get-all-dependencies/42287.

@jondwillis
Copy link
Author

@paulb777 Thanks, I agree. I added to the thread that you linked to. Overall the SPM<>Xcode integration seems quite buggy.

@paulb777
Copy link
Member

Thanks @jondwillis. I would add the distinction about SPM <> Xcode integration bugginess specifically for binary packages. The source package integration has been more stable.

@paulb777
Copy link
Member

@jondwillis Does Xcode 12.5 address this?

@jondwillis
Copy link
Author

jondwillis commented Feb 12, 2021

@paulb777 ...sort of! ... with some changes, thanks to improved Xcode-SPM error messaging.

For context, this was my local swift package's Package.swift:

...
    dependencies: [
        .package(url: "https://github.com/Quick/Quick.git", from: "3.0.0"),
        .package(url: "https://github.com/Quick/Nimble.git", from: "9.0.0"),
        .package(url: "https://github.com/firebase/firebase-ios-sdk", from: "7.4.0"),
    ],
    targets: [
        .target(
            name: "Analytics",
            dependencies: [
                .product(name: "FirebaseAnalytics", package: "Firebase"),
                .product(name: "FirebaseCrashlytics", package: "Firebase"),
            ]),
            ...

Without any changes to my example project in Xcode 12.5 beta, I received the following error when resolving packages:

unknown package 'Firebase' in dependencies of target 'Analytics'; valid packages are: 'Quick', 'Nimble', 'firebase-ios-sdk'

I decided to bump to version to 7.6.0 at this time, and remove the firebase dependency from my project's Swift packages. Then I tried changing the local dependency's dependencies package name to firebase-ios-sdk, e.g.:

.product(name: "FirebaseCrashlytics", package: "firebase-ios-sdk"),

Which allowed the dependency's dependency to resolve. However, when re-adding Firebase to my project's Swift package, I got another error:

product dependency 'FirebaseAnalytics' in package 'firebase-ios-sdk' not found

Seems circular! That then led me to the solution, removing the project's Firebase dependency again, then adding an explicit name to my local dependency's product dependencies, and re-adding my projects Firebase dependency (including in case the order here matters):

...
dependencies: [
        .package(url: "https://github.com/Quick/Quick.git", from: "3.0.0"),
        .package(url: "https://github.com/Quick/Nimble.git", from: "9.0.0"),
        .package(name: "Firebase", url: "https://github.com/firebase/firebase-ios-sdk", from: "7.6.0"),
    ],
    targets: [
        .target(
            name: "Analytics",
            dependencies: [
                .product(name: "FirebaseAnalytics", package: "Firebase"),
                .product(name: "FirebaseCrashlytics", package: "Firebase"),
            ]),
...

I updated my toy project repo with the working solution.

⚠️ for future folks stumbling upon this, I did notice while going back and replaying these steps for this write-up, the previous broken behavior appeared again unexpectedly, so maybe this needs to all happen in a really specific order, or can still occur transiently.

@paulb777
Copy link
Member

@jondwillis Thanks for sharing your journey and solution. I'm going to close since the sporadic functionality is almost certainly a Swift Package Manager and not specifically the Firebase implementation.

@firebase firebase locked and limited conversation to collaborators Mar 15, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants