https://github.com/simonnickel/fb13094487-package-product-not-found
https://github.com/simonnickel/fb13094487-package-product-not-found
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/simonnickel/fb13094487-package-product-not-found
- Owner: simonnickel
- Created: 2023-09-06T14:39:07.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-09-08T08:29:55.000Z (over 1 year ago)
- Last Synced: 2025-04-01T15:10:22.727Z (about 2 months ago)
- Language: Swift
- Size: 3.91 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# FB13094487 - Swift Package Manager fails to resolve dependency with different name than url
## Solution
Apple Engineering team kindle responded with a solution:
```
targets: [
.target(
name: "SNLTheme",
dependencies: [
// Solution: (instead of ["FB13094487PackageProductNotFound"])
.product(name: "FB13094487PackageProductNotFound", package: "FB13094487-package-product-not-found")
]),
.testTarget(
name: "SNLThemeTests",
dependencies: ["SNLTheme"]),
]
```This does work and cleares the warning. However, I still think is a change for the worse compared to the previous API. The Package name should be declared where the package is defined.
## Issue
Swift Package Manager fails to resolve a dependency that has a different package name than its url suggests:
.package(url: "https://github.com/simonnickel/FB13094487-package-product-not-found.git", branch: "main"),
The url is /FB13094487-package-product-not-found.git, while the package name is FB13094487PackageProductNotFound.
It fails with the following error:
x-xcode-log://F414219F-DBD0-4A2A-AC10-E043451FEA5A product 'FB13094487PackageProductNotFound' required by package 'snl-theme' target 'SNLTheme' not found.Using the deprecated dependency definition works:
.package(name: "FB13094487PackageProductNotFound", url: "https://github.com/simonnickel/FB13094487-package-product-not-found.git", branch: "main")As this is deprecated, it always shows a warning.
Full Package Definition:
import PackageDescription
```
let package = Package(
name: "SNLTheme",
products: [
.library(
name: "SNLTheme",
targets: ["SNLTheme"]),
],
dependencies: [
// Does work, but deprecated:
// .package(name: "FB13094487PackageProductNotFound", url: "https://github.com/simonnickel/FB13094487-package-product-not-found.git", branch: "main"),
// Does not work:
.package(url: "https://github.com/simonnickel/FB13094487-package-product-not-found.git", branch: "main")
],
targets: [
.target(
name: "SNLTheme",
dependencies: ["FB13094487PackageProductNotFound"]), // <- Causes it to fail.
.testTarget(
name: "SNLThemeTests",
dependencies: ["SNLTheme"]),
]
)
```