Relative path references in Package.swift dependencies do not work with Skip Fuse
Consider a package uses a local dependency "SomeLocalDependency" referenced by a relative path to the Package.swift file:
// swift-tools-version: 6.1
// This is a Skip (https://skip.tools/) package.
import PackageDescription
let package = Package(
name: "my-fuse-project",
products: [
.library(name: "MyProject", type: .dynamic, targets: ["MyProject"]),
],
dependencies: [
.package(url: "https://source.skip.tools/skip.git", from: "1.6.5"),
.package(url: "https://source.skip.tools/skip-fuse-ui.git", from: "1.0.0"),
.package(name: "SomeLocalDependency", path: "../../Packages/SomeLocalDependency")
],
targets: [
.target(
name: "MyProject",
dependencies: [
.product(name: "SkipFuseUI", package: "skip-fuse-ui"),
.product(name: "Alamofire", package: "Alamofire"),
.byName(name: "SomeLocalDependency")
],
plugins: [.plugin(name: "skipstone", package: "skip")]
),
]
)
This is a valid Swift package, but when building for Android as part of a Skip application, the build will fail with an error like:
FAILURE: Build failed with an exception.
* What went wrong:
Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'.
> Could not resolve all dependencies for configuration ':app:debugCompileClasspath'.
> Could not resolve project :skipstone: SomeLocalDependency.
Required by:
project :app > project :skipstone:Bricksee
> No matching variant of project :skipstone: SomeLocalDependency was found.
The issue is that Skip Fuse's native Android build creates a derived Package.swift in a different location because we need to add some code to the Package.swift file, but the fact that it is being built from a separate folder means that relative path references are no longer valid.
The best workaround (aside from pushing the repository somewhere and referencing it through a git https) is to change the relative path to an absolute path. E.g.:
.package(name: "SomeLocalDependency", path: "../../Packages/SomeLocalDependency")
would become:
.package(name: "SomeLocalDependency", path: "/path/to/project/Packages/SomeLocalDependency")
One thing we might do is at least raise a warning or error when we detect that the package uses a relative path. Another option could be to actually identify when the package is using a relative path and re-write it to use the absolute path equivalent.