Plugin to facilitate debugging iOS applications using Kotlin Native in Xcode. Defines Kotlin files as source code, with basic highlighting. Allows you to set breakpoints and includes llvm support to view data in the debug window. Xcode does not officially support custom language definitions, but they also don't explicitly block them.
We're looking for a Mobile Developer, with Android/Kotlin experience, who is eager to dive into Kotlin Multiplatform Mobile (KMM) development. Come join the remote-first team putting KMM in production. More info here.
There are 2 parts to Kotlin support: 1) debugging support and 2) language color and style formatting.
You need to tell Xcode that *.kt
files are source files, and run an lldb formatter script when debugging starts. Advanced users may want to do this manually, but if you have Xcode installed in the default place, you can run the setup script.
Unless you're using Xcode 11 (in which case look here for help), the following script will install both debugging and formatting support:
./setup.sh
If properly set up, you should be able to add Kotlin source to Xcode, set up breakpoints, and step through code. To add Kotlin source to Xcode, follow these steps:
- Add a New Group to the Xcode project.
- Add Files to the newly created group (Kotlin Debug in this instance).
- Select the folders in the Kotlin library that are directly relevant to the iOS build, which will usually be
commonMain
andiosMain
. Make sure "Copy items into destination group's folder (if needed)" is unchecked.
When you're done, your Xcode project structure should look something like this:
The project used as an example above is KaMPKit. Check it out if you want to see a project that already includes Kotlin file references in Xcode. It's an excellent template for Kotlin multiplatform mobile projects.
Setting up the Plugin has been an amalgam of various source projects, as Xcode "Plugins" are undocumented. The most significant piece, the language color file came from other color files shipped with Xcode. Xcode plugin file from GraphQL
LLDB formatting originally comes from the Kotlin/Native project, source konan_lldb.py, although the way data is grabbed has been heavily modified to better support an interactive debugger.
Check out the Discussions.
Every time Xcode is updated we need the UUID. It needs to be added to Kotlin.ideplugin/Contents/Info.plist
. To find the
UUID of your version of Xcode, run the following:
defaults read /Applications/Xcode.app/Contents/Info DVTPlugInCompatibilityUUID
Info from here