Kotlift alternatives and similar libraries
Based on the "Misc" category.
Alternatively, view Kotlift alternatives based on common mentions on social networks and blogs.
* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest. Visit our partner's website for more details.
Do you think we are missing an alternative of Kotlift or a related project?
[Kotlift: The first source-to-source language transpiler from Kotlin to Swift](banner.png)
Kotlift helps you to write business logic once, and reuse most of the code on iOS. Porting an app from Android to iOS will be faster and less error-prone. With Kotlift, Kotlin truly is the Swift of Android.
The program is not intended to support the full Kotlin or Swift language, but most of the generated Swift code will be valid. All framework interfacing code from Android or iOS/Cocoa is not supported. Many functions from the Kotlin stdlib are the same in Swift, therefore less logic has to be rewritten.
Supported versions: Kotlin 1.0.1, Swift 2.2
The following language features are currently transpiled, but some edge cases might produce invalid Swift code.
- Variables, arrays and lists
- Basic types (String, Boolean, Double, Float, Long, Int, Short, Byte)
- Functions with parameters
- If and elvis operator
- For and while loops
- String interpolation
- Main function calling (in Swift playground)
- Custom rewrites (comment the preceding line with
// SWIFT: this.will(be.replaced)to replace the following line)
- Null safety, safe calls, null coalescing
- Basic try-catch
- @Throws annotation / throws
- Ranges and iteration
- When / switch case
- Classes with none or one constructor
- Abstract classes
- Interfaces / protocols
- Data classes (constructor and description will be generated)
- Extension functions
- Companion objects / static class properties
- Properties with getters and setters / backing fields / computed properties
- Visibility modifiers
- Basic lambdas / closures
- Maps / dictionaries
- Very basic smart casts
The following features are currently unsupported, but are ordered by likelihood to be implemented soon:
- (Data) classes, functions or getters & setters with opening & closing brackets in same line or without brackets at all
- Line-wrapped function and class definitions
- Unnamed constructor parameter
- Unnamed function parameters (except the first one)
- Auto inferred function return types
- Finally / defer
- Full support for smart casts
The repository contains an IntelliJ project. Usage of the precompiled jar:
java -jar moshbit.kotlift.jar test-src dest replacementFile.json test-dest
- parameter: folder of Kotlin source files. (mandatory)
- parameter: destination folder where Swift code should be written to. (mandatory)
- parameter: replacement file, used for standard language replacements and may be customized. (mandatory)
- parameter: Swift testcase folder. If given, all files in the destination folder are compared to the files in this folder. (optional)
Kotlift uses various regular expressions and a simple structure tree.
For advanced Kotlift usage in your project, modify replacementFile.json to customize
replacements (such as
.mySwiftyToStringFunction()). Include the kotlift.swift file
in your project for a basic mapping of the most important Kotlin std-lib functions that are different in Swift.
- Kotlin 1.0.1
For every transpiled language feature there is a Kotlin test file in test-src and a Swift file in test-dest. Executing Kotlift with a fourth argument not only transpiles all test files, but also checks them for any differences.
Pull requests are welcome. If you add new features, please add Kotlin and Swift test files.
Please contact [email protected] for any inquiries.