Giter Club home page Giter Club logo

xcode-kotlin's Introduction

Kotlin Native Xcode Support

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.

We're Hiring!

Touchlab is looking for Android-focused mobile engineers, experienced with Kotlin and looking to get involved with Kotlin Multiplatorm in the near future. More info here.

Xcode 11+

Xcode does not officially support custom language definitions, but they also don't explicitly block them. However, Xcode 11 introduced several breaking changes from earlier versions, and some resolutions are still outstanding.

Xcode <= 10.x

For earlier versions, please see xcode10 branch. Life moves on, and we'll only be supporting Xcode 11+.

Installation

There are 2 parts to Kotlin support: 1) debugging support and 2) language color and style formatting.

Step 1: Debugging Support

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.

./setup.sh

Step 2: Formatting Support

In Xcode 11, you need to move some files into a protected area. Some users may not want to do this, and may possibly not have permissions to do this. You'll need to run the script with sufficient permissions, which generally means sudo.

You can still debug Kotlin without formatting support, just FYI. This step is not required.

sudo ./colorsetup.sh

Kotlin 1.3.6x Issue

Using static frameworks and/or Cocoapods may remove debug info in this version. More info here

Special Note

All of that magic was sorted out by Ellen Shapiro, who undrestands all of this far better than I ever will.

Tracking Issue Here

Usage

If properly set up, you should be able to add Kotlin source to Xcode, set up breakpoints, and step through code.

We're deprecating the Xcode Sync plugin. Add folder reference instead! See issue. Description and video coming soon.

To help automate adding Kotlin source, check out the Kotlin Xcode Sync Gradle plugin.

Sample

The Droidcon NYC app has both the Xcode Gradle sync and Xcode projects enabled for debugging.

Sources

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.

Possible Future Stuff

Color File

The color definition is basically Java's with minor additions. This could be better adapted to Kotlin.

Install

It's a bash script, which works, but does not take into account non-standard install directories and various other possible config options. This could be improved.

From Swift

You can see variables when you're debugging Kotlin, but when you're in a swift file that has a class that came from Kotlin you can't see much. It would be great to be able to improve that.

Better Debug Alignment

This happens in the Kotlin compiler, so it's a little deeper, but the breakpoints don't always track with the source when there are more complex structures (lambdas, etc). This should improve over time.

Xcode Updates

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

xcode-kotlin's People

Contributors

ben-whit-ley avatar idstein avatar jblorenzo avatar karottenreibe avatar kpgalligan avatar paraselene 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.