Skip to content

SPM: Explicit declarations for external dependencies#832

Merged
johnfairh merged 2 commits intojpsim:mainfrom
ailinykh:dependency-requires-explicit-declaration
Mar 31, 2025
Merged

SPM: Explicit declarations for external dependencies#832
johnfairh merged 2 commits intojpsim:mainfrom
ailinykh:dependency-requires-explicit-declaration

Conversation

@ailinykh
Copy link
Contributor

When I tried to build my project using Xcode 16, I got an error:

error: 'sourcekitten': dependency 'Yams' in target 'SourceKittenFramework' requires explicit declaration; reference the package in the target dependency with '.product(name: "Yams", package: "yams")'
make: *** [build] Error 1

@johnfairh
Copy link
Collaborator

I don't mind taking this change; that said, do you understand what is different about your environment/project settings that's triggering this?

@ailinykh
Copy link
Contributor Author

ailinykh commented Mar 24, 2025

Here is what my setup looks like:

graph TD;
    MyProject-->MyPrivateProject;
    MyPrivateProject-->Yams;
    SourceKitten-->Yams;
    MyProject-->SourceKitten;
Loading

so I suppose that SPM can't make a decision what Yams to use when it comes to build SourceKittenFramework. Should it checkout a new one, or it could rely to MyPrivateProject's dependency

SourceKitten is 0.37.0
Yams is 5.3.1 (in both cases)

@ailinykh
Copy link
Contributor Author

ailinykh commented Mar 24, 2025

I made more precise research and what I've found:

  1. Error message comes from ModulesGraph.swift
  2. The productDependencyMissingPackage error thrown from ModulesGraph+Loading.swift
  3. The comment above says:

// Starting in 5.2, and module-based dependency, we require module product dependencies to
// explicitly reference the package containing the product, or for the product, package and
// dependency to share the same name. We don't check this in manifest loading for root-packages so
// we can provide a more detailed diagnostic here.

Therefore I suspect that the root cause is target name Yams matches the package name Yams and SPM can't resolve it

@johnfairh
Copy link
Collaborator

Well, neither of those ideas speak to why your project is the only one affected, but the change is good & will hopefully help others in the future too -- thank you for the PR!

@johnfairh johnfairh merged commit 0b2cd2e into jpsim:main Mar 31, 2025
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants