Hi, everyone, I am Chengxiang Ink shadow!
Since Last December, Kotlin’s team announced that Kotlin/Native support and Objective-C/Swift calls each other, in effect saying that Kotlin will likely support mixed development with Objective-C/Swift projects in the future.
This means that in the future, we can use Kotlin to develop iOS apps directly.
If you don’t know about Kotlin/Native, please read the official documentation.
https://kotlinlang.org/docs/reference/native-overview.html
Simply put, Kotlin/Native is a technique for compiling Kotlin into Native binaries that are not supported by any virtual machine. Kotlin/Native doesn’t have to rely on a variety of JVMS for Java code to run on different platforms. It compiles directly and generates executable binaries for the corresponding platform.
According to the documentation, Kotlin/Native currently supports the following system platforms:
- Windows (x86_64 only at the moment)
- Linux (x86_64, arm32, MIPS, MIPS little endian)
- MacOS (x86_64)
- iOS (arm64 only)
- Android (arm32 and arm64)
- WebAssembly (wasm32 only)
It can be said that Kotlin/Native has great development potential in the future.
Today, the Kotlin team announced that they are working on a Kotlin/Native plug-in for AppCode, bringing us one step closer to using Kotlin for iOS development.
AppCode is a MacOS-only IDE designed for iOS/macOS developers. It already supports Xcode projects, runs on emulators and devices, debugs, and provides broader support for Objective-C and Swift.
If you want to try Kotlin/Native, download the latest Version of AppCode 2018.1.1 and install the Kotlin/Native for AppCode plugin from the JetBrains plugin page.
It is important to note that the plug-in is still under active development, and it has some wobbles, such as high memory consumption.
Next, let’s experience the charm of Kotlin/Native.
Creating a new project
Kotlin/Native uses Gradle as a build tool. To compile a Kotlin/Native project using Xcode, you need to add a run script to the project that calls Gradle to build Kotlin/Native code.
Designing a similar project from scratch would be a bit cumbersome, so Kotlin/Native comes with several iOS and macOS templates to simplify the process:
Once the project is created, build and start it in the emulator with a simple click of the “Run” button.
Note that the current directory of the Kotlin code is not marked as the source root directory, so some operations (such as creating a new Kotlin file) may be incorrect. To solve this problem, mark the SRC /main/ Kotlin directory as the project source directory.
Code Insight
AppCode itself is a Kotlin plugin based on IntelliJ IDEA, so many of the Kotlin features can be directly applied to Kotlin/Native code. For example: code review, refactoring, etc.
Test
The AppCode plug-in supports writing test code using the Kotlin.test framework.
The SDK documentation
Kotlin/Native itself is a standard API that calls Objective-C, and provides a very easy way to read the API documentation for that.
summary
As you can see from this article, Kotlin/Native is “playable” right now, but it still has a lot of features to work on.
Let’s look forward to Kotlin/Native’s new features.
This article is partly sourced from Kotlin Blog (Roman Belov) and compiled by Chengxiang Moying.
Today, I reply to “grow up” in the background of the official account, and I will get some learning materials sorted out by me. I can also reply to “add group”, so that we can learn and progress together.
Recommended reading:
- Comics: Programmer, can you “manage” your product manager?
- App multi-language translation, machine translation can be lightning fast!
- 2017 Most Authoritative Blockchain Report (download included)
- Learn about Flutter on Google!
- Remote control intelligent TV, the program has been open source!