Relative path references in Package.swift dependencies do not work with Skip Fuse
Nobody has claimed this yet.
- Dominant language
- Swift
- Stars
- 3.2k
- Forks
- 106
- Avg merge
- 6d 13h
- Merged PRs (30d)
- 1
Description
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Package.swift dependency handling and the derived Package.swift created for the native Android build. Trace how relative path dependencies are processed after the file is moved, then determine whether the finished change should report the invalid reference or preserve its original location; verify the behavior with a local dependency such as SomeLocalDependency.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, swift
- Domain
- build-system, mobile
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100