Bokeh

Making sense of the mess in my head

Exploring Uncut - April 7th, 2025

Battery low

As you might have noticed, there was no post last week. I had a couple of bullet points in my note but come Sunday evening, I had not started writing any draft. I was also contemplating writing a more in-depth article on a particular topic, as I did before, but I could not decide on which one and commit to it.

I just needed to disconnect and relax and did not have the energy for it.

So instead of pushing through it, most probably missing the point of what I had to say, or shifting by one day, I decided to just skip a week.

So here is an update on what happened during the last two weeks.

Embedded Swift Community Hour

On Friday, March 28th, the second edition took place.

Kuba started by doing a show and tell of configuring SourceKit-LSP with Embedded Swift on different editors so code completion would work correctly.
The main attention points are:

  • you need a working build in CMake first for SourceKit-LSP to work
  • the CMAKE_EXPORT_COMPILE_COMMANDS is required (a compile_commands.json file must be present)
  • you must make sure (e.g. check in the logs) that SourceKit-LSP picks up the correct toolchain.
    If Xcode is not installed, exporting a TOOLCHAINS variable will not work. You then need to add the /usr/bin folder of your toolchain to the PATH variable.
    Now that swiftly 1.0 has been released, it’s the easiest method to install and reference Swift toolchains.

The open discussion then moved on to debugging and other pain point areas of Embedded Swift development. I mentioned one, where the linker would fail with no error message whatsoever.
I went on to implement a test project showing such a case. You can find it in EmbeddedSwift-nRF52-ClassVsStruct.
Kuba replied a few days later with a solution for this particular case. It turns out the optimization level was causing the issue. Using -O instead of -Osize fixes the issue.
I would like to further understand how the optimization level is affecting the generated code and causing the link issue. This aligns with the research I started doing several weeks ago on getting a better understanding of SIL and LLVM IR. Still a lot of work on that front.

iOS Dev Happy Hour

On Saturday, I had some availability in the afternoon and so attended the iOS Dev Happy Hour virtual meet-up for the first time.

Vincent Pradeilles 👨🏻‍💻 started with a presentation of some interesting SwiftUI features introduced in previous versions of iOS (from iOS 15 onwards). I always find this kind of presentation useful as it’s nearly impossible to remember all the SwiftUI types and modifiers unless you use them frequently. Moreover, when you’re faced with a particular problem, finding the appropriate way to tackle it is also not easy. Having regular reminders of how people use SwiftUI to implement particular UI/UX behaviors helps me deal with that.

After the presentation, the participants split into different discussion rooms, where smaller groups (of around 10 people maximum) can chat about a particular topic or simply get to know each other.
I had the opportunity to discuss upcoming conferences, AVFoundation, and visionOS as well as get to know some community members (and say hello to some I already know).

I enjoyed the format a lot, which remembers me of the vibe and energy you get from networking at physical conferences. I’ll definitely try to be part of future occurrences.

BLE in Embedded Swift

Last week, in The Swift Programming Language Discord, somebody posted a question about working with BLE in Embedded Swift. As I had done quite a bit of work on that for my Arc Reactor project, I happily answered.

But I never published the BLE code as it required cleanup. It was rushed together just in time for it to be ready for a conference talk. Twice!
The first time, for Pragma in November 2024, I had quite a bit of C glue code to relay between the Zephyr BLE API and my Swift code. That bothered me.
Later, for FOSDEM in February 2025, I managed to get rid of the C code altogether. But it was still prototype code with known issues (e.g. memory leaks).
At that time, I also started putting together smaller examples showing specific features of using BLE from Embedded Swift. The goal was to publish that code and write a series of articles to accompany it. But I put that on hold and never progressed on it.
Now that I know these examples would actually benefit someone, I’ll take the required time to publish something.
I’ll publish the examples on GitHub at Embedded Swift version of the Nordic Dev Academy BLE examples. The first example is already online, others will follow as I find the time to properly implement them.

That’s it for this week, as always, feel free to get in touch on Mastodon, I’d love to hear your thoughts.