vinivendra/Gryphon
Fork: 46 Star: 606 (更新于 2024-11-04 08:06:38)
license: NOASSERTION
Language: Swift .
The Swift to Kotlin translator.
最后发布版本: v0.19 ( 2022-06-26 11:00:08)
⚠️ Repository archived
This project has been archived and is no longer maintained. The original maintainer is no longer able to dedicate the time required to keep Gryphon up to date with the recent Swift releases. The code is preserved here for any who may want it, and the original Readme.md
follows below:
The Swift to Kotlin translator
Gryphon is a program that translates Swift code into Kotlin code. It was created to enable mobile app developers to share parts of an iOS app's codebase with Android.
- Risk-free. Stop using Gryphon whenever you want - you'll still be able to read and understand your Kotlin code, even the computer-generated parts.
- No editing needed. Translated Kotlin files work the same as the Swift files they came from.
- Xcode integration. Translate your iOS code to Android, compile the Android app, and see Kotlin's errors and warnings in the Swift lines that originated them - all without leaving Xcode.
- Custom-made. Use special comments and templates to customize your Kotlin translation, and use any platform-specific features you want - even in translated source files.
👍 Status
Gryphon is now in preview! 🎉
This means the main systems and ideas have already been implemented - for instance, it's been translating a complete version of its own codebase for a while now. However, users often find new bugs to be fixed. If that's the case, feel free to report a new issue on GitHub.
You can also check out the currently supported translations for the Swift standard library here.
📲 Installing
Gryphon supports both macOS and Linux. You can install it with:
Homebrew
Use Homebrew to install Gryphon and its dependencies automatically:
$ brew install vinivendra/gryphon/gryphon
Mint
Use Mint to install Gryphon using the Swift package manager:
$ mint install vinivendra/Gryphon
GitPod
Try it out on GitPod before downloading:
Building from source
Clone the repo run the installation script:
$ git clone https://github.com/vinivendra/Gryphon.git
$ cd Gryphon
$ ./Scripts/install.sh
Docker
Install it in a Docker container:
$ git clone https://github.com/vinivendra/Gryphon.git
$ cd Gryphon
$ docker build -t gryphon .
$ docker run -it --rm --privileged -v /absolute/path/to/current/directory/:/app/Gryphon gryphon
# ./Scripts/install.sh
📖 Guides
Check out the Tutorial to get started. It covers the basic information needed to begin using Gryphon, whether you want to translate command line programs, translate a new iOS app to Android, or add Gryphon to an existing app.
There are also more advanced guides on using collections, using translation comments, and using templates
📘 Frequently asked questions
What is Gryphon?
Gryphon is a command line application that can translate Swift code into Kotlin code. It was especially designed to enable app developers to translate platform-independent parts of their iOS apps into code they can use in their Android apps.
Can I compile and run the translated code or do I need to fix it first?
Gryphon's output code is meant to behave just like the input code that created it. It's still possible technically to generate Kotlin code that doesn't compile - for instance, if you try to translate unsupported Swift features, or if there's a bug - but as a rule, you should be able to translate, compile and run supported code without the need for post-translation edits.
Will I be able to understand the translated code?
One of Gryphon's main goals is to make sure translated code can be understood by human beings. As a rule, if you understand the input Swift code, you should also be able to understand the translated Kotlin code - if you don't, feel free to file a bug report.
This is done within some realistic constraints: the priority is that the translated code has to behave correctly, for instance. Gryphon attempts to find a "reasonably understandable Kotlin" middle ground somewhere between "machine-code-like Kotlin" and "perfectly idiomatic Kotlin".
Can I translate anything written in Swift?
Gryphon's support for Swift features is constantly evolving. It is currently capable of translating many of the main features one might expect - classes, structs, enums, closures, extensions, protocols, etc - enough that it currently translates around 97% of a version of its own codebase (the other 3% are platform-specific files). Some Swift features are just waiting to be implemented, while others can't be translated to Kotlin and may never be supported.
What Swift versions can Gryphon translate?
Gryphon currently supports Swift 5.2 to 5.5. It will use whatever Swift version was used to build it, so if you build the Gryphon binary using Swift 5.5 then that's the version it will assume all your Swift code is in. You can find out which Swift version your Gryphon binary uses by running gryphon --version
.
Due to some technical limitations, only Swift 5.3, 5.4 and 5.5 are being tested in the latest versions of Gryphon. If you have any difficulties with Swift 5.2, please let us know.
Can Gryphon help translate my existing iOS app?
Yes - but it will need some adaptations (though probably less than your average multiplatform framework). This depends on your application - how similar app's architecture is to its Android counterpart, how often your code uses Swift features unsupported by Gryphon, etc.
It's worth noting that, like other transpilers for app development, Gryphon is best suited for translating platform-independent logic code. There's currently no support for translating calls to UIKit, for instance - and there's no telling if that will happen someday.
It is recommended that you start by translating only a few platform-independent parts of your code, adding new files incrementally. It might help to use architectures with clear separations between UI code and logic code - like MVP and MVC to separate the code that can be translated. For more information, check out Adding Gryphon to an existing app.
Can I use Gryphon to translate a non-iOS app?
Yes. While Gryphon's main focus is on iOS-to-Android support, it is primarily a Swift to Kotlin translator, and it doesn't require anything iOS-specific to run. You can use it on Linux to translate command line tools, for example. Even Gryphon's own source code can be translated, and that's just a command-line tool with nothing iOS-related.
Will it ever support translating Kotlin code to Swift? What about other languages?
Probably not. The challenges involved in translating Swift code into Kotlin are very specific for these two languages. Translating Kotlin into Swift would require a new front-end for Kotlin, a new back-end for Swift, and all-new logic in the middle to turn one into the other - basically, a whole new Gryphon. The same goes for other combinations of languages.
How can I help?
Thanks for the offer!
If you want to suggest a way to improve Gryphon, feel free to open a new issue. All bug reports and feature requests are welcome and encouraged - we can't fix it if we don't know about it!
If you would like to contribute directly, first check out the contributor's guide to learn to set up your environment. Then, if you're looking for inspiration, take a look at some good first issues (if you're new to Gryphon) or the beginner-friendly first timers only (if you're new to open source) - or, if you already know what you want to do, open an issue and let's talk about it.
If you're going to contribute, you should probably read the code of conduct too.
最近版本更新:(数据更新于 2024-09-15 06:54:39)
2022-06-26 11:00:08 v0.19
2021-11-09 10:23:51 v0.18.1
2021-09-25 09:34:35 v0.18
2021-09-09 08:59:31 v0.17
2021-07-19 05:14:40 v0.16.1
2021-07-05 09:22:07 v0.16
2021-06-28 09:58:55 v0.15
2021-05-17 06:23:44 v0.14
2021-01-07 00:47:12 v0.13.1
2020-12-31 03:19:43 v0.13
vinivendra/Gryphon同语言 Swift最近更新仓库
2024-11-03 04:20:56 argmaxinc/WhisperKit
2024-11-01 03:30:19 wordpress-mobile/WordPress-iOS
2024-10-30 03:29:03 jordanbaird/Ice
2024-10-24 23:32:54 whoeevee/EeveeSpotify
2024-10-24 02:02:47 Artificial-Pancreas/iAPS
2024-10-23 00:57:58 pointfreeco/swift-composable-architecture