Swift Packages for ESP-IDF

Hi Swift Community :wave:

Building upon Swift Matter Examples and Embedded Swift Example Projects, I could not help myself but to try building a project template to bring the Swift Package Manager to ESP. And as of today, I think I succeeded. This brings the power of Swift Packages to the embedded platform, all complete with modular code that can interact with the platform APIs or Components from The ESP Component Registry.

Additionally, I was able to convince SourceKitLSP to play along beautifully, making development for embedded devices (esp32c6 in this case) feel right on par with "normal" Swift development.

You can find the template along with setup instructions here. Please give it a try and let me know what you think!

9 Likes

This is super cool :sunglasses:

Am I right that the instructions are Linux specific (because of swiftly) but there's nothing actually Linux specific in the template and it should be straightforward to get it to work on macOS?

This is correct. You might need to adjust a few fields in the main/CMakeLists.txt to get SourcekitLSP working, namely the SWIFT_LSP_TARGET might be different for you.

You can find out which target you need by creating/building a new package and looking into the .build directory. There should be a folder with a target triple, e.g. x86_64-unknown-linux. The folder name is what you need.

Of course, make sure that all programs/commands used are available. The required programs/commands are rm tr sed grep echo ln ar mv and cut. Because macOS is unix-based I expect them to be all available by default, so this should be no problem.