The Problem

Editing code on iOS sucks. Apple's UITextView is a joke for anything beyond plain text: no syntax highlighting, no line numbers, and zero awareness of invisible characters or indentation. If you want a real code editor on iOS, you usually end up cobbling together hacks or relying on garbage webviews. Runestone fixes this.

What This Does

Runestone is a Swift framework for making an actual code editor on iOS. It uses GitHub's Tree-sitter (see Example/Languages/Sources/TreeSitterJavaScript/) for fast, incremental parsing and syntax highlighting. You get line numbers, invisible character display, code-aware insertion (auto-pairing quotes/brackets), and customizable themes. The core lives in Sources/Runestone, with docs in Documentation.docc and demo code in Example/.

Customization isn't just a checkbox—want your own theme? Check out the Example/Themes/Sources/RunestoneOneDarkTheme/OneDarkTheme.swift. Adding languages is straightforward: look at highlights.scm and injections.scm in the JavaScript example. All the little editor features (line wrapping, page guide, overscroll, regex search) are handled in the framework, not bolted on.

Real-World Use

Say you want a SwiftUI app that edits JavaScript. You’d drop in the Runestone package, set up a TextView (see MainViewController.swift in the example), and wire up a TreeSitterLanguage for JS. Themes are just Swift structs—grab TomorrowNightTheme.swift, tweak colors, and set it as your editor theme. Invisible characters and line numbers are one-liners. You can even detect indentation style automatically, so your editor stops mangling tabs and spaces.

textView.language = TreeSitterLanguage.javascript textView.theme = TomorrowNightTheme() textView.showLineNumbers = true

The Bottom Line

Runestone is what Apple should've shipped for code editing. It's fast, flexible, and actually respects developer needs. If you're building an iOS code editor or need a solid text input for dev tools, use it. For simple note apps, it's overkill. For anything code-related, it's the best option unless you hate Swift or want to reinvent the wheel.