Plug: a plugin management library for Swift

This year I decided I wanted to start playing with Swift again. I decided to write a small back-end project with Vapor and everything's going well. However, I needed a way to add functionality at runtime so I wouldn't have to recompile my project everytime I wanted to change something. This resulted in a small library for managing plugins (which are just dynamic libraries).

(docs are here: Documentation)

It was very fun writing this library. It uses macros (finally!!!) so you can easily write plugins.
The library does everything you'd expect: it loads, unloads and reloads plugins. You communicate with them by using an API based on Node.js's EventEmitter, except it's way prettier. It also has some security features, such as checking the MD5 hash of the plugin.

It's great to see how the Swift ecossystem is evolving. Swift-DoCC is amazing, support for Linux is even better nowadays, the language feels more "stable", etc. And swift-mmio? That's a game changer. 2024 is the year of Swift!

12 Likes

When I think about what is missing in comparison to Java which I used a lot in my old non-Swift life, such a plugin mechanism is the first thing that comes to my mind (although I have read that there had been changes in Java 16 making this more difficult, but I am not in the Java world any more).

Well, MD5 is not a very secure hash, even SHA-1 is not considered “secure” any more these days.

1 Like