Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Swift package manager #3788

Merged
merged 14 commits into from
Jun 3, 2024
Merged

Conversation

keshav-space
Copy link
Member

@keshav-space keshav-space commented May 28, 2024

Tasks

  • Reviewed contribution guidelines
  • PR is descriptively titled 📑 and links the original issue above 🔗
  • Tests pass -- look for a green checkbox ✔️ a few minutes after opening your PR
    Run tests locally to check for errors.
  • Commits are in uniquely-named feature branch and has no merge conflicts 📁
  • Updated documentation pages (if applicable)
  • Updated CHANGELOG.rst (if applicable)

Signed-off-by: Keshav Priyadarshi <[email protected]>
Signed-off-by: Keshav Priyadarshi <[email protected]>
Copy link
Contributor

@pombredanne pombredanne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! here are a few feedbacks for you consideration

There are likely a few extra things to consider:

Unrelated this https://github.com/tuist/tuist/tree/25d90e3a3d613caf6a740a03ea4d195a685a0feb/fixtures/app_with_spm_dependencies/Tuist has some interesting things:

  • a workspace
  • development dependencies (they cannot be tagged as such anywhere in Swift syntax)

src/packagedcode/swift.py Outdated Show resolved Hide resolved
src/packagedcode/swift.py Outdated Show resolved Hide resolved
src/packagedcode/swift.py Outdated Show resolved Hide resolved
src/packagedcode/swift.py Outdated Show resolved Hide resolved
src/packagedcode/swift.py Outdated Show resolved Hide resolved
datasource_id=cls.datasource_id,
type=cls.default_package_type,
primary_language=cls.default_primary_language,
namespace=None,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add namespace

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pombredanne We don't have a namespace for the top-level package in the Package.swift manifest.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, how does this look like when installed?
Is there any trace of where it came from?
https://github.com/mapbox/mapbox-maps-ios/blob/main/Package.swift has some possible base URL. BUT when I see https://github.com/map-ir/mapir-ios-maps-sdk/blob/cfca260d03ab8f0d1889795ec012adae1d3bfbd8/Package.swift#L20 or https://github.com/mapbox/mapbox-navigation-ios/blob/b9c235e665ea2d3b7cd096e9c6128e97c1d4f00c/Package.swift#L27 it is clear that the actual name is one thing and the "package name" is another thing and seem to be resolved only when interpreting a Package.swift for dependencies.

So IMHO we cannot get that actual correct PURL name short of matching or have this used as a dependency. Just create a follow up issue for this so we can address it later.

Copy link
Member Author

@keshav-space keshav-space May 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, how does this look like when installed?
Is there any trace of where it came from?

Yes, we can trace the source of an already installed package from the .build directory.

Tracking this issue here #3793

The PURL for a Swift package depends on where the package is hosted, and given that Package.swift does not contain the repository URL for the top-level package, it is not possible to infer the correct PURL for the top-level package solely from the Package.swift manifest.
We can use https://swiftpackageindex.com/ to get the correct PURL, but this may not work for all packages since Swift Package Index is not authoritative in nature, i.e. a Swift package may exist, and the author may choose not to add their package to Swift Package Index. https://swiftpackageindex.com/add-a-package

src/packagedcode/swift.py Outdated Show resolved Hide resolved
src/packagedcode/swift.py Show resolved Hide resolved
src/packagedcode/swift.py Outdated Show resolved Hide resolved
keshav-space and others added 9 commits May 29, 2024 21:23
Signed-off-by: Keshav Priyadarshi <[email protected]>

Co-authored-by: Philippe Ombredanne <[email protected]>
Signed-off-by: Keshav Priyadarshi <[email protected]>

Co-authored-by: Philippe Ombredanne <[email protected]>
Signed-off-by: Keshav Priyadarshi <[email protected]>

Co-authored-by: Philippe Ombredanne <[email protected]>
Signed-off-by: Keshav Priyadarshi <[email protected]>

Co-authored-by: Philippe Ombredanne <[email protected]>
Signed-off-by: Keshav Priyadarshi <[email protected]>

Co-authored-by: Philippe Ombredanne <[email protected]>
Signed-off-by: Keshav Priyadarshi <[email protected]>

Co-authored-by: Philippe Ombredanne <[email protected]>
- Use the last segment as name and the rest as namespace

Signed-off-by: Keshav Priyadarshi <[email protected]>
@keshav-space
Copy link
Member Author

Thanks @pombredanne, addressed all your feedback.

Copy link
Contributor

@pombredanne pombredanne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All good. Please merge.

@keshav-space keshav-space merged commit 8e9dc46 into develop Jun 3, 2024
34 checks passed
@keshav-space keshav-space deleted the 2657-support-swiftpm branch June 3, 2024 10:59
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.

Add support for Swift PM
2 participants