Thought I’d create a new topic, as this is a tangent from the original. Context; I’ve been working on my own Glyphs python stubs for better type hinting / autocomplete / having docs right in front of my face. My background is in Swift. @FlorianPircher mentioned that Swift is entirely possible to use, for scripting in Glyphs.
I’d seen talk of this here and there, but for some reason it felt too niche/scary, so I didn’t look into it properly. Florians youtube video was really helpful, helped demystify it a lot.
I’ve got a few questions that come to mind, before jumping right into it, would love insight from anyone with some experience using Glyphs+Swift.
Are there any obvious gotchas to be mindful of? I’m sure it’s not the case now, but e.g. I read a few posts about compatibility issues with Swift plugins — but this was from 2017, so likely not an issue now?
Is the API surface more or less one-to-one, compared with Python?
I understand most of the resources/examples out there are python-based. But I suspect the broader concepts will be the same, and differences will come down to implementation details?
I prefer building UI programmatically, have always opted for vanilla over Interface Builder. Just confirming, we aren’t limited to IB, right, if choosing swift? If anything, we’re far closer to native, and can probably just use AppKit/Cocoa classes directly?
Generally speaking, are there certain scenarios where it’d make much more sense to reach for python over swift, or vice versa? I’m wondering whether quick scratch-pad style scripting might be easiest using python, and longer-term / bigger projects with Swift?
I would say that Python plug-ins are easier to get started with and updating them is simpler as you just need to push a new Git commit with the latest source code changes. For Swift, you need to build the plug-in bundle for distribution and for updating push that bundle.
The compiled nature of Swift also means that you don’t need to manage external dependencies, like with Python, as you can compile your dependencies directly into your bundle.
It might look a bit more complicated at the beginning, but as soon as you start to use auto layout (and you should, and again learning that takes a bit effort), it is much easier.
And one more thing to consider: Swift can be much faster than python.
Thanks for these resources, Florian. I’m so glad you pointed to Swift for this, it’s been really pleasant to work with — esp. once I got my head around the main differences between the two pipelines. Having all the ObjC types / auto complete etc right there is a dream. I’ve even been able to selectively import some of my own swift packages, so I have my familiar tooling right in there as well. Many thanks.
Also I was not expecting to be able to do ⌘R and have Xcode literally close+reopen Glyphs with my new changes. Game changer ha.
You can do that with other IDEs too. Since I’m so used to building and running from Xcode with ⌘R, I added that to VSCode as well for any Python plugin development work.