· 3 min read Posted by Touchlab Engineering

Xcode Kotlin Plugin Fixed for Xcode 15!

The Xcode Kotlin plugin from Touchlab allows you to browse and debug Kotlin code from within Xcode. Xcode 15 has a bug that would cause it to crash with any language support plugin. This new release provides a workaround.

Touchlab publishes a plugin that provides source code color highlighting for Kotlin, and allows you to debug Kotlin code for iOS apps from inside Xcode.

touchlab/xcode-kotlin

This is a critical tool for teams building native iOS UI’s, especially Swift UI, on top of any shared Kotlin code.

The Issue

With the release of Xcode 15, people with our plugin installed could no longer run Xcode. It’s not just that our plugin didn’t work, Xcode actually crashed. The only way around this was to remove our plugin.

Through some very serious detective work, in particular Sniper-yj with some deep details, and TadeasKriz on our end piecing it together, there is a workaround.

To be clear, this isn’t a security check that’s failing. There’s an Xcode bug, and an ongoing conversation with the Xcode team, to hopefully resolve it. In the meantime, you can use the plugin, but be aware of how it works.

The Update

The workaround requires some extra steps during install to apply. Also, the place where the output of these steps “lives” is in a cache, which Xcode/Mac may decide to delete at any time. That means at some point Xcode may start crashing on startup again. If that happens, you need to run a new task with this release of xcode-kotlin.

xcode-kotlin fix-xcode15

This should repair the workaround, after which Xcode should work normally.

Our workaround for the Xcode 15 bug may occasionally need to be repaired because the info lives in a cache controlled by Xcode/Mac. If Xcode won’t open, run the command above.

Xcode and Plugins

Several years back, there was a thriving plugin ecosystem for Xcode. None of this was condoned by Apple, but it seemed to have been tolerated for an extended period. However, after some issues with plugins inserting malicious code into apps, Apple took steps to shut down Xcode plugins.

While this applies to most plugins, source highlighting plugins were allowed to continue. There has never been any official communication from Apple about this, but presumably, source highlighting plugins don’t do anything that is a security issue. They simply tell Xcode that a certain file type is “source code”, which allows you to add breakpoints in the editor, and allows for providing a source highlighting definition file.

Our “plugin” actually doesn’t do anything special for debugging. That is done through standard lldb access and a lldb file provided by JetBrains (although we added quite a bit of optimization early on to make GUI tools usable).

While technically a plugin, our plugin doesn’t really do anything that is a concern. However, as demonstrated with Xcode 15, Apple also does not care about these plugins, and is most likely unaware of them completely. We run the risk of losing the ability to debug Kotlin with every release (we had something similar, although far less difficult to resolve, with Xcode 11).

If anybody in the Kotlin community had deep ties to the Xcode team, we’d all appreciate a nudge on resolving this issue