vinivendra / Gryphon

The Swift to Kotlin translator.
https://vinivendra.github.io/Gryphon/
Other
609 stars 46 forks source link

Support Swift Package Manager #86

Open LouisCAD opened 4 years ago

LouisCAD commented 4 years ago

Hi, here's the problem: I'd like to have MongoKitten converted to Kotlin.

Unfortunately, it currently doesn't work because Swift Package Manager dependencies are used (for Swift NIO and other source libraries that depend on Swift NIO too.).

Swift NIO definitely has equivalents in Kotlin libraries, the Android platform and Java libraries. I can find them if needed.

I'd like this project to support converting libraries that depend on other Swift libraries so long as these are source libraries (and not binary libraries), or at least for select libraries like Swift NIO and other first-party Swift libraries.

vinivendra commented 4 years ago

Hi! Thanks for bringing this to my attention. SPM support sounds like a great idea, but it's been a while since I've thought about it.

This isn't supported right now because the current frontend is based on AST dumps from the Swift compiler, and I don't know how (or even if it's possible) to get those AST dumps for a Swift Package Manager project. I just asked about it on the forums, though, so here's hoping.

The good news is that I'm working on rewriting that frontend (to use SwiftSyntax and SourceKit instead of the AST dumps), and I think the new implementation will be more stable and more compatible with things like the Swift Package Manager. Once that's done, I can come back to this issue.

If you still want to move forward in the meantime, I'd suggest trying to change the files you want to translate so that you can compile them with swiftc (instead of swift build). This might involve, for instance, replacing references to the SwiftNIO API with your own protocols (or empty classes, etc). The swiftc compilation doesn't have to be functional, but if it compiles without errors you should be able to run Gryphon on it.

Let me know if I can help with anything.

LouisCAD commented 4 years ago

Sounds good!

Please, let me know if it doesn't go as expected and you need ideas for ways to support this :)