I’ve never written a Xojo plugin before. I can read but have never written anything substantial in C or C++.
Is it at all feasible to write a plugin for macOS only using Swift? Swift is a language I use frequently in addition to Xojo.
I’ve never written a Xojo plugin before. I can read but have never written anything substantial in C or C++.
Is it at all feasible to write a plugin for macOS only using Swift? Swift is a language I use frequently in addition to Xojo.
I’m no expert in this, but I’ll go out on a limb and say: No.
A pity because, like you, if you could use Swift to code plugins I’d be more likely to move in that direction. However, there’s the issue of cross-platform compatibility in my case, which I suspect knocks another wheel off the cart…
It’s possible, but a pain.
Much easier inside Xcode than with build scripts.
And you’d use the interoperability between Swift and C/C++.
So the Xojo code calls a C++ function in a cpp file, which calls a function in the Swift code.
Hmm.
Perhaps I could call into the swift library with declared rather than a plugin?
Sure. But you can’t use Swift types as parameter. Xojo may not get the same structure layouts as Swift.
I wonder what you look into there?
I already managed to get some Swift code into MBS Xojo Plugins with the ImagePlaygroundMBS class.
I remember @Greg_O made some steps to use Swift libraries with Xojo (don’t know if he even got this work with Swift Plugins).
I basically want to rewrite my ObjoScript scripting language in a faster language that Xojo. I figured Swift would be a good choice.
I don’t get it, why not raw C ? Swift is relatively slow. So would seem to be strange choice if you wanted to make in faster language.
What i did was build a bridge for obj-C to Swift for use with Declares so any of the swift-only frameworks can be accessed.
What’s behind your claim of Swift being a lot slower than C? This might have been the case years ago but it looks like Swift has really caught up as the compiler has been optimized.
I code for fun and I don’t enjoy C or C++. I absolutely hate manual memory management and am not very good at it.
I’m not sure how slow Swift is compared to C but an early version of my VM written in swift is an order of magnitude faster than the Xojo implementation.
This all started because the scripting language I wanted to use (Wren) doesn’t implement step debugging. If you fancy adding that to the Wren implantation Björn I’d happily pay for your time!
Do you have a public link for this?
The bridge is project specific. I did one each for the products i sell for macOS and iOS, WeatherKit and Multipeer Connectivity.