Is it possible to let local SwiftPM import other dependencies library from project

Hi there, I'm newbie here, and i had run into a small question of using local package recently, which is about import project's other library into my local package.

Assuming that my project had already add a dependency from remote github, such as Alamofire, GRDB...etc, do i need to add that remote dependency at local Package.swift file again?

the Package.swift that i set like below

dependencies: [
        .package(url: "https://github.com/Alamofire/Alamofire.git", from: "1.0.0") <-- version need to be same as project 
    ],

targets: [
        .target(
            name: "X",
            dependencies: [
                "Alamofire"
            ]
        )

I was little confuse that if i have multiple local package which all need to use that same remote library, when the library have to update version in the future that every local package will also need to revise version in Package.swift as same as project update version.

and i try before if doesn't write dependency in Package.swift, the Xcode will present the No such module XXX(the remote one) error for me. but if write, and it build success.

pleas let me know if there have anything else that i can setting in project or Package.swift file. Thanks

It is possible if version can be resolved, but seems like there is a conflict therefore you are facing an error. For example if actual version of dependency is 0.7.14, you depend on .upToNextMajor(from “0.5.0”) and some other dependency depends on .upToNextMinor(from: “0.7.0”) then everything should work and you’d get the latest version (btw for 0.x.x versions you should depend on next minor instead of major to avoid fetching breaking changes, but it’s a different topic), but if the latest version is 1.0.0 and you depend on 1.0.0+ then the dependency will cause a conflict

I guess that your dependency uses some older version of Alamofire, the easiest fix is to downgrade your Alamofire to the version that your dependency uses, but it’s better to fork and update outdated dependency :tipping_hand_man: