If you're looking for more information, I have How do closures work (memory management) and maybe this post also lightly touches the topic Dynamically loading a Swift `shared object` / `dylib` .
At the first glance I don't see anything wrong (albeit the callback casting seems a little clumsy to me). The context of those Swift closures never "leaves" the Swift environment - worst case scenario: those closures are never released by the dictionary that retains them.
My only concern would be, that if you're in multi-threaded environment, the access to the callbacks
dictionary should be done in a safe manner.