Giter Club home page Giter Club logo

gryphon's Introduction

Gryphon logo

The Swift to Kotlin translator

Swift package manager compatible open ethical licensed ethically Gitpod Ready-to-Code first-timers-only Follow on Twitter

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 its own codebase for a while now. However, new users might still find some new bugs to be fixed. If that's the case, feel free to report a new issue on GitHub.

๐Ÿ“ฒ 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:

Open in Gitpod

Building from source

Clone the repo run the installation script:

$ git clone https://github.com/vinivendra/Gryphon.git
$ cd Gryphon
$ ./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
# ./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.

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 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.

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 helo 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.

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.

gryphon's People

Contributors

barrault01 avatar pt2121 avatar sgade avatar vinivendra avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.