Swiftpack.co - Package - vinivendra/Gryphon
Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
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 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:


Use Homebrew to install Gryphon and its dependencies automatically:

$ brew install vinivendra/gryphon/gryphon


Use Mint to install Gryphon using the Swift package manager:

$ mint install vinivendra/Gryphon


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
$ ./Scripts/install.sh


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.

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.


Stars: 382



v0.13.1 - 2021-01-06T16:47:12


  • Improve support for #if GRYPHON by including it on all SourceKit requests
  • Support float literals even on autoclosures (e.g. foo ?? 1.0)

v0.13 - 2020-12-30T19:19:43


  • Removed the legacy frontend, now only SwiftSyntax is supported.
  • Improved support for enums with raw values.
  • Lots and lots of cleanup in the codebase.

v0.12 - 2020-12-24T14:18:15


  • Support protocol inheritance (#88, solved in #95 by @IgorMaineti)
  • Support comments in xcfilelists with # (#93)
  • Support hex and binary numbers like 0x101 and 0b101 (#94 by @troy-lamerton)

v0.10.6 - 2020-11-19T04:59:14


  • New frontend based on SwiftSyntax and SourceKit. The legacy frontend (based on AST dumps) is being deprecated, but can still be accessed with --legacyFrontend.


  • Support subscripts with multiple parameters.
  • Remove // gryphon annotation: override in some cases.
  • Remove // gryphon annotation: multiline.
  • Support // gryphon pure comments for function calls.
  • Support // gryphon pure comments for templates.
  • Raise side-effect warnings for calls inside arguments.
  • Raise warnings for unknown operators.
  • Non-trailing closures are translated as non-trailing.
  • Support declaring generic classes.
  • Support let _: T = ...
  • Support List(array).
  • Support list.array.
  • Support let list: Array = ...


  • Fix lots of race conditions.
  • Fix capitalization of nested enums.
  • Fix inheritances for nested types with the same name.
  • Lots more...

v0.10.5 - 2020-10-15T02:45:44


  • Add a Status.md file to keep track of the current status of standard library translations.


  • @codersanjeev improved the error messages for native Arrays and Dictionaries.

v0.10.4 - 2020-09-10T01:32:34


  • Automatically escape $ characters in Kotlin strings to avoid accidental string interpolations (#3 by @codersanjeev).

v0.10.3 - 2020-08-27T00:48:31


  • Fix crash when translating empty protocols with inheritances (#87).

v0.10.2 - 2020-08-06T00:39:35


  • Support earlier versions of Ruby (tested with 2.4 and 2.6).


  • Rename the master branch to release.

v0.10.1 - 2020-07-15T21:57:40


  • Fix Homebrew installation of Xcodeproj.
  • Fix bugs that prevented support for Swift 5.3.

v0.10 - 2020-07-09T02:04:31


  • Support static variables in extensions (#74).
  • Raise warnings when unsupported initializers are found in structs (#70).
  • Support let _ = <expression> (#69).


  • Support single-expression functions (#75) and getters (#80), both by @sgade.
  • Avoid translating description as toString() when we know the type doesn't conform to CustomStringConvertible (#71).
  • Fix labeled returns on closures when they refer to functions with named arguments (#67).

For the future

  • Lots of work on supporting SourceKit and SwiftSyntax, which would solve a lot of bugs and let us support Swift 5.3.

v0.9 - 2020-06-24T21:36:18


  • Structured templates available in user code and used throughout the codebase (#65).


  • Added support for inits in the algorithm that calculates access control modifiers (#61).
  • Fixed init calls that weren't translated with the correct parameter names (#62).

v0.8 - 2020-06-18T00:14:15


  • Add support for Homebrew.
  • Add project to the Swift Package Index
  • Update calls to bash scripts in the tutorials.
  • Fix the silhouette favicon for safari.


  • Add translation for Array.removeAll().


  • Implement structured templates for the stdlib translations, which should solve a lot of bugs (#24).
  • Support types with parentheses (#49).
  • Support calls to optional functions (#50).
  • Support consecutive declarations in if lets (#54).
  • Add translations for numeric casts between Ints, Doubles and Floats (#53).
  • Other small bugfixes.

v0.7 - 2020-06-12T15:11:39

Note: re-posting this release to fix a problem with the git tag.


  • Support for installing with Mint, which also means better support for the Swift package manager.
  • Improvements for logs with --verbose, which should make it a lot easier to diagnose user bugs (#42).
  • Added the ability to choose which Xcode target to translate (#40, reported by @massimobio).
  • Removed the instructions for opening the Package.swift file in Xcode, which doesn't seem to work well (reported by @barrault01).
  • @barrault01 removed extra braces from function declarations in protocols (#46) and made the bash scripts executable (#45).


  • @barrault01 fixed a bug where Void sometimes wasn't being translated to Unit (#47).

For the future

  • Started implementation of structured templates, which should solve a lot of sneaky bugs related to standard library references.

v0.6 - 2020-06-11T23:43:28

Note: version 0.6 was actually published on 27/5/2020. This release is being created now just so it's included in GitHub.


  • Fixed an issue some users were having when trying to output a translation to the console;
  • Add return@label in closures to avoid returning to the root function (#14);
  • @pt2121 implemented a pass to remove break statements in switches (#17);
  • Add parentheses around or operators in if conditions to avoid issues with operator precedence (#18);
  • Support trailing closures on simple tuple shuffle expressions;
  • Removed extra output from automated tests;
  • Lack of a second Swift toolchain is now just a warning, not a test failure;
  • Fixed the favicon for safari and iOS.


  • Added instructions on an issue (#3) especially for first-time contributors to open source.


  • Added test scripts, which should make running the tests a lot easier for everyone;
  • Improved several things on the contributor's guide;
  • Wrote templates for bug reports, feature requests, and pull requests on GitHub;
  • Added a GOVERNANCE.md file to the repo;
  • Started using the ethical Hippocratic license (v2.1);
  • Fixed lots of typos on the website.

For the future

  • Started looking into using SourceKit instead of the AST dumps, which should greatly improve stability and reliability in general.

Stable Beta 0.3 - 2019-10-14T20:57:50

This release contains a relatively stable version of the Gryphon prototype. It's being created to be shared in academic citations.

Stable Beta 0.1 - 2018-07-13T23:13:40

This release contains a relatively stable version of the Gryphon prototype. It's being created to be shared in academic citations.