iOS development with JetBrains Fleet

Romain Boisselle
Kodein Koders
Published in
6 min readNov 26, 2023

Farewell, AppCode; we’ve found a worthy replacement.

This article is intended to demonstrate how to use JetBrains Fleet for the development of Swift/UI applications, including SwiftUI previews.

For those who may not know about JetBrains, it is an amazing company that builds tools for developers, such as IntelliJ IDEA or Kotlin. To me, JetBrains has always provided tools that exceeded my developer expectations, even when those tools are considered “not stable.”

A year ago, JetBrains announced Fleet, a brand new distributed and polyglot IDE. While many people saw it as just another VSCode IDE, I knew it would become more than that. Bringing collaborative work for remote developers and providing multiple language support out-of-the-box is a real game-changer. And if you’ve already tried a JetBrains IDE, you know that they are serious about developer productivity!

In the meantime, a year ago, they discontinued AppCode, an underrated IDE for working within the Apple ecosystem. AppCode was particularly helpful for developers who found it challenging to adjust to alternative IDE workflows, such as XCode.

With Fleet, you will experience easy code navigation, refactoring, collaboration, and support for a wide range of languages and project types, including SwiftUI applications.

Let’s be honest, you won’t completely escape from Xcode — there are still essential tasks like project configuration, signing, and package dependency management that require its user interface. However, for the majority of your coding sessions, you’ll find that you won’t need it anymore.

Edit and run your iOS app from Fleet

Let’s start by installing Fleet using the JetBrains Toolbox. This is the easiest way to manage and upgrade your JetBrains IDEs in one place.

JetBrains Toolbox
JetBrains Toolbox — IDE version management

Once Fleet installed, you can either use your own SwiftUI project or clone the following GitHub project created for this article’s purpose.

https://github.com/KodeinKoders/playground-fleet-swiftui

JetBrains Fleet
JetBrains Fleet IDE

Now, you can try to run the application by hitting the run button in the top right corner, or just use the ^R shortcut.

JetBrains Fleet run window
JetBrains Fleet — Run dialog

At this point, it might work if you have recently opened XCode and/or built and run an iOS project. Otherwise, you will likely encounter an error, such as the following:

JetBrains Fleet — Build error

This is certainly because your project’s environment is not ready to use any XCode toolchain. This can happen if you have never opened XCode or if you have just booted your Mac. The simplest solution is to open your project in XCode and build it once using CMD+B. Then you can close it and come back to Fleet.

Afterwards, you will be able to edit and run your iOS app from Fleet, even if you reboot your Mac!

Add custom run configuration that works with Fleet

Fleet allows you to define your own configuration to build and run your code. With Fleet, you can create multiple run configurations to target different schemes/devices without leaving the Fleet interface or going through XCode.

We can can create a run.json file inside a .fleet/ directory at the root of our project, such as the following example:

In this case, we define that our application needs to use the Xcode toolchain, that it should run on a iPhone 15 simulator with iOS 17, using the debug configuration.

A nice thing here is, if your project’s environment is correctly detected via the XCode toolchain, the available destination devices will be auto-completable.

JetBrains Fleet — Run configuration

To find our different run configurations, simply click the run button or use the ^R shortcut.

JetBrains Fleet — Run dialog
JetBrains Fleet — Application running

Bonus: SwiftUI Preview with Fleet and InjectionIII

One of the major benefits of developing with declarative UI frameworks like Jetpack Compose or SwiftUI is the ability to use tooling to preview your UI without having to build your application every time.

For this purpose you can use InjectionIII. Combined with Fleet, this project can be used as a file watcher, to hot reload SwiftUI changes, directly in your iOS Simulator.

Install it, directly from the Mac App Store

Mac App Store — InjectionIII

Once installed, launch InjectionIII. You will find a small blue syringe icon in your menu bar. Click on it, then select “Open Project” to target the project you want to watch. This will allow it to inject changes into an iOS Simulator.

InjectionIII — Menu

Before running your application in the simulator and hot reload UI modification, you need to add debug specific code to your project. At the initialisation phase of the project, add the following if block.

This code will include the InjectionIII binary in your iOS/MacOS app, but only for the debug configuration.

Likewise, in your SwiftUI preview code, you will need to make a slight change in order to define what you will be injecting into the Simulator.

Now you can run your application onto an iOS Simulator. And when you will change some SwiftUI files, they will be injected directly inside this simulator instance, like in the following demonstration:

JetBrains Fleet holds great promise for the future of IDEs. It is polyglot, collaborative, and expected to be much lighter than IntelliJ IDEA.

However, like any alpha product, there are some drawbacks. For instance, at the time of writing this article, you won’t be able to define breakpoints to debug your iOS application, and the fact that we depend on the Apple toolchain may break your workflow at some point.

However, the benefits are already evident. Even in its public preview, Fleet has excelled in every type of project I’ve worked on — whether it was Kotlin code, Android, backend, Kotlin Multiplatform projects, or platform-specific code such as pure Swift and SwiftUI projects. It has never failed me. This becomes even better when working with Kotlin Multiplatform code; being polyglot by essence, it allows us to seamlessly navigate between different technologies, from Kotlin to Swift in a glimpse. This is a real breeze.

This article is brought to you by Kodein Koders, a European service & training provider focused on Kotlin & Kotlin/Multiplatform. Do not hesitate to visit our reach out through our website.

--

--