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

SPM can't find firebase dependencies #6357

Closed
StarLard opened this issue Aug 28, 2020 · 4 comments · Fixed by #6496
Closed

SPM can't find firebase dependencies #6357

StarLard opened this issue Aug 28, 2020 · 4 comments · Fixed by #6496
Assignees
Labels
beta-software Related to using beta iOS or Xcode versions. Swift Package Manager

Comments

@StarLard
Copy link

StarLard commented Aug 28, 2020

Step 0: Are you in the right place?

  • For issues or feature requests related to the code in this repository
    file a Github issue.
    • If this is a feature request please use the Feature Request template.
  • For general technical questions, post a question on StackOverflow
    with the firebase tag.
  • For general (non-iOS) Firebase discussion, use the firebase-talk
    google group.
  • For backend issues, console issues, and other non-SDK help that does not fall under one
    of the above categories, reach out to
    Firebase Support.
  • Once you've read this section and determined that your issue is appropriate for
    this repository, please delete this section.

[REQUIRED] Step 1: Describe your environment

  • Xcode version: Version 12.0 beta 6 (12A8189n)
  • Firebase SDK version: 6.31-spm-beta
  • Firebase Component: Auth, Core, Analytics, Firestore
  • Component version: 6.31-spm-beta
  • Installation method: Swift Package Manager

[REQUIRED] Step 2: Describe the problem

Steps to reproduce:

What happened? How can we make the problem occur?
This could be a description, log/console output, etc.

When attempting to include Firebase SDK as dependency through SPM...

Expected:
Xcode finds and includes the products.

Actual:
Xcode will generate error: "produce dependency 'FirebaseProductNameXYZ' in package 'firebase-ios-sdk' not found" for each product listed in dependencies.

If you have a downloadable sample project that reproduces the bug you're reporting, you will
likely receive a faster response on your issue.

Relevant Code:

let package = Package(
    name: "SomePackage",
    platforms: [ .iOS(.v14), .macOS(.v11), .tvOS(.v14) ],
    products: [
        .library(
            name: "SomePackage",
            targets: ["SomePackage"]),
    ],
    dependencies: [
        .package(url: "https://github.com/firebase/firebase-ios-sdk.git", .branch("6.31-spm-beta"))
    ],
    targets: [
        .target(
            name: "SomePackage",
            dependencies: [
                .product(name: "FirebaseAnalytics", package: "firebase-ios-sdk", condition: .when(platforms: [.iOS])),
                .product(name: "FirebaseAuth", package: "firebase-ios-sdk"),
                .product(name: "FirebaseCore", package: "firebase-ios-sdk"),
                .product(name: "FirebaseFirestore", package: "firebase-ios-sdk"),
                .product(name: "FirebaseFirestoreSwift", package: "firebase-ios-sdk"),
            ],
        )
        .testTarget(
            name: "SomePackageTests",
            dependencies: ["SomePackage"]),
    ]
)

@ryanwilson
Copy link
Member

ryanwilson commented Aug 28, 2020

Thanks for the report @StarLard - there were a few issues with the copy/pasted code (like a missing ) to close the .target( but after I cleaned it up I was able to reproduce the issue.

EDITED
It looks like this may be somewhat working as intended... it's expecting to match with the name specified in our own Package.swift manifest, in this case it's "Firebase".

Changing to "Firebase" should work, I'll see if this is an Xcode specific issue or a SwiftPM issue and go from there.

ORIGINAL RESPONSE BELOW, INCORRECT

I'm not sure exactly why that's the case though, it looks like that should be the correct default name: https://github.com/apple/swift-package-manager/blob/96b0ff907fdd4d91fcd207f4c49aae4fce1d9ec5/Sources/PackageModel/Package.swift#L140-L161

Regardless, a workaround for now is to add name: "Firebase" to the .package in the dependencies argument before the url, then change to package: "Firebase" for each product in the target itself.

Funnily enough, even explicitly adding name: "firebase-ios-sdk" instead of name: "Firebase" also fails for me so I'll have to see if I can figure out what's going on there.

@ryanwilson ryanwilson added Swift Package Manager beta-software Related to using beta iOS or Xcode versions. and removed api: auth labels Aug 28, 2020
@ryanwilson
Copy link
Member

Follow up:

It looks like this is working as intended based on this package resolution code:
https://github.com/apple/swift-package-manager/blob/6f469cf0c7c03591ac0723baa134b5d42855e3c1/Sources/PackageGraph/PackageGraphLoader.swift#L327-L338

(shout out to Swift Package Manager for being open source).

I'm going to post on the forums asking about this because it's unclear to me what this means if you have two different dependencies that offer the same package name. Need to do a bit more reading on SE-0226, then after I get that posted, I'll close this issue since we have the right method.

@StarLard
Copy link
Author

StarLard commented Aug 28, 2020

Thanks for the quick reply Ryan! I'll give that a try.

Update

Adding name: argument to the .package declaration allowed dependencies to resolve as expected. Thanks @ryanwilson! Maybe we could add this to the Firebase SPM installation documentation? I don't think I've had to do this for other frameworks so it would be a useful call-out.

ryanwilson added a commit to ryanwilson/GitHub-6357 that referenced this issue Sep 18, 2020
@ryanwilson
Copy link
Member

Finally added a note to the Swift forums with a repro, showing that it's impossible to have two dependencies with the same package name. https://forums.swift.org/t/cant-consume-two-swift-packages-with-the-same-name/40408. I'll update the instructions for us then close this bug, thanks!

ryanwilson added a commit that referenced this issue Sep 18, 2020
This is for developers not integrating with Xcode.

Fixes #6357
ryanwilson added a commit that referenced this issue Sep 18, 2020
* Update instructions for manual Package manifests.

This is for developers not integrating with Xcode.

Fixes #6357

* Whitespace removal.

* Review feedback
@firebase firebase locked and limited conversation to collaborators Oct 19, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
beta-software Related to using beta iOS or Xcode versions. Swift Package Manager
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants