Swift Package Manager issues with unversioned Packages (example: firebase-ios-sdk)

Viewed 2383

I'm working on pulling out some of the functionality on one of my apps into a package so that I can centralize some reused code, and in doing so I pulled the dependency to firebase into my package. As soon as I did this, I can no longer get updates to my package because of the following error:

Failed to resolve packages

because no versions of mobile.ios.MYPACKAGE match the requirement 1.0.7..<2.0.0 and package mobile.ios.MYPACKAGE is required using a version-based requirement and it depends on unversion package firebase-ios-sdk, mobile.ios.MYPACKAGE >=1.0.6 is forbidden. And because root depends on mobile.ios.MYPACKAGE 1.0.6..<2.0.0, version solving failed.

This error makes sense since my Package.swift has a reference to firebase-ios-sdk, which is currently in beta. This is alright because I don't plan on releasing my pacakge till firebase exits their beta later this year.

My reference to the package inside of dependencies array:

dependencies: [
    .package(name: "Firebase",
               url: "https://github.com/firebase/firebase-ios-sdk.git",
               .branch("6.32-spm-beta")),
...

My reference to the firebase package inside of my targets array

    targets: [
    .target(
        name: "MYPACKAGE",
        dependencies: ["Alamofire", "SwiftyJSON",
            .product(name: "FirebaseAuth", package: "Firebase"),
            .product(name: "FirebaseCrashlytics", package: "Firebase"),
            .product(name: "FirebaseAnalytics", package: "Firebase"),

You can see I'm referencing the 6.32.spm-beta as firebase instructs you to do in their docs. How can I get past this issue so that I can work on integrating my package with my application while firebase is still in its beta?

1 Answers

There is a version based dependency, if you are adding your package by version so you have to add dependencies by version not from branch:

Note: don't forget to tag your commits(in your package).

for example:

dependencies: [
    .package(name: "Firebase",
     url: "https://github.com/firebase/firebase-ios-sdk.git",from: "1.0.0")
]
Related