Closed AF-cgi closed 2 years ago
@mono0926 are you already working on support for this?
@BetweenTwoBits
Not yet, and not planned, sorry. I'm welcome the pull request 🐶
@ykws Yes, I know. That's the way what we currently do. But it's pretty hard to rename all your dependencies and find the correct naming for each of this dependencies.
@AF-cgi Good!
I think too, however it is impossible to rename automatically, because of the breaking change that the source of the origin package name was lost.
I think we can only manually renaming as mention above configuration.
Just an idea,
We may be able to pick up the name from Package(name:
in Package.swift,
we can access each location
in Package.resolved as repository url.
Just an idea,
We may be able to pick up the name from
Package(name:
in Package.swift, we can access eachlocation
in Package.resolved as repository url.
That's a good idea and I implemented it in my fork. However there are caveats to this: since Package.swift is not a JSON where we can rely on standardized parsing, we might encounter problems with some Packages. As an example from my own Swift Package, I don't like repeating myself in Swift and since the Package Definition is written in Swift, I defined my Package Name as a String variable. That's perfectly valid, but breaks any attempts I took when trying to parse the name in a globally valid way.
What I did in the end is a 3-step process to get the best name possible from the new version of Package.resolved:
Package
object, removing all nested code inside [...]
to eliminate dependency and target names and finally getting the remaining value for name
. If anything fails we return nil
which lets us fall back to the result of Step 2.Let me know if you see room for improvement since this is my first draft and all the parsing made me dizzy at times (trying a lot of Regex before landing on my solution). Edge cases I encountered are also added as Unit Tests, so you can play around in the parser with confidence.
A more robust way of parsing the Package.swift would be to run swift package dump-package
and parse its JSON output. With that approach, all future formats would be supported.
With the new Package.resolved JSON version 2 (#174), which Apple introduce with Xcode 13.3 and Swift 5.6, I miss the correct package names. The possibility to improve the names is the rename-feature of your tool. Do you have any idea if there is a better way, to get the correct package names? An example:
Each package name is lowercase. Most package names ends with
-sdk
,-iOS-sdk
or-apple
.