I have a local swift package Foo which provides two different libraries Foo and FooB. Now I would like to use them in another local package Bar. I am only able to get the whole package by path declaration. Is there a way to name/specify which library should be used? I want to use FooB in my Bar Package.
let package = Package(
name: "Foo",
products: [
.library(name: "Foo", targets: ["Foo"]),
.library(name: "FooB", targets: ["FooB"])
]
...)
let package = Package(
name: "Bar",
dependencies: [
.package(path: "Foo"),
.package(path: "FooB") // this one does not work
],
...)
// inside package Bar
import Foo
import FooB // this is throwing "no such module 'FooB'"
Here's a concrete example:
Foo
Playing
Foo, IGListKit Package.swiftexcerpts:
…
Bar
In the role of
Bar, in its entirety:Pruned Package
after importing, the Package.swift of
Fooin the Package Dependencies section states only:It seems that Xcode / SPM is pruning the imported package to contain only one of the three libraries in this package. (Initially, the second library's code was missing, one my my syntaxes caused it to be pulled, but the first was not seen. They are now both there, but only one is seen.)
I couldn't determine a syntax to make it bring down both.
Current Error
Xcode 15.0 beta (15A5160n)
Additional Thoughts
package(name:url:_:) (and the
nameproperty ofPackage.Dependency) has been deprecated, but you need to use the name of the package dependency to use in the specific target dependency.This leads me to believe there is a newer syntax that this that should be used.
Resolution
Instagram doesn't fully support Swift Package Manager for IGListKit
(There are better solutions than IGListKit, but this is in legacy code. Currently, there are 191 commits between the
4.0.0tag and the HEAD of the repository; it's been 3+ years since a release was made.)The problem in this case was that the latest tag (as of Jun 2023) is the
4.0.0tag, and the version of thePackage.swiftfile is literally the abbreviated version I was receiving.Everything worked when I updated, and simplified the description to look at the commit that added the support. (Could have used
mainbranch, but that will keep changing.)