tkrajacic
(Thomas Krajacic)
1
I can use Bundle on macOS to load a framework at runtime, and that works reasonably well even with Swift (given the principal class is @objc). Can I do something similar under Linux?
A similar question has been posted quite a while ago without any answer (How do you dynamically load a module on Linux?)
Given that Swift has advanced quite a bit, is this possible now?
Can I load a framework/dylib under linux at runtime and use it? Bundle seems to be mostly unimplemented in corelibs foundation.
Lope
(Ján Kosa)
2
It is definitely possible to load dylib in linux using swift, I made a little example app couple months ago to document a bug in SPM. You can see implementation here:
there are two related projects, one that defines plugin's interface and other that show how actual plugin is implemented:
Not sure if this is exactly what you need, but it is possible to load your own dylib and interface with it
2 Likes
tkrajacic
(Thomas Krajacic)
3
Ok the problem here is that only C functions can be called, and Swift libraries are not really supported.
I guess my question is if there is any kind of story or roadmap on how and when this is planned to be properly supported (not just on Linux). I mean even on macOS the requirement to only use Obj-C protocols leaves a lot to be desired.
Anyone? @Tony_Parker?
1 Like
I think we can start with a JIRA, for the Linux bit.
This may depend on ABI and module stability; otherwise loading some bit of Swift code that was not compiled with the rest of your code may result in some strange behavior.
4 Likes
tkrajacic
(Thomas Krajacic)
5
Thank you Tony for your answer. Makes sense that it is tied to ABI stability. I can't wait though when Swift on Linux is fully usable™
Should I file the issue on Jira? I guess you are a lot better at wording it though 
1 Like
felix91gr
(Félix Fischer)
6
Maybe @Aciid knows something about this
?
1 Like
Please feel free to create one yourself, and put a link here. Thanks!
tkrajacic
(Thomas Krajacic)
8