Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 381
Unome Avatar asked Sep 22 '20 20:09

Unome


People also ask

Does firebase support loading via Swift Package Manager?

Loading status checks… Starting with the 8.0.0 release, Firebase officially supports installation via Swift Package Manager. Prior to version 8.0.0 (starting with version 6.31.0) support was in Beta.

What is the name of the package in Swift?

The manifest file, called Package.swift , defines the package’s name and its contents using the PackageDescription module. A package has one or more targets. Each target specifies a product and may declare one or more dependencies.

What version of myPackage is required for Firebase?

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.

How do I run a swift project in Xcode?

open Package.swiftor double click Package.swiftin Finder. Xcode will open the project Choose a scheme for a library to build or test suite to run Choose a target platform by selecting the run destination along with the scheme Adding a New Firebase Pod


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")
]
like image 116
SomuYadav Avatar answered Oct 14 '22 00:10

SomuYadav