I am trying to write a Quick Look plugin with Swift. I am able to build successfully by change the .c to .m. However, I couldn't find a way to let the swift dylibs loaded. I pointed the runpath to @load_path/../Frameworks but it kept on "being ignored in restricted program because it is a relative path". Does that mean I am not able to build a quick look plugin in Swift?
Is it possible to write Quick Look plugins in Swift?
No. You could probably make this work but it’s definitely not safe.
The fundamental problem here is the Swift runtime. Quick Look plug-ins are hosted in a system process and it’s possible that that system process might load multiple plug-ins. If there are two plug-ins written in Swift, they might have different versions of the Swift runtime and that will not end well.
There’s two ways forward here:
Eventually Swift will reach ABI stability, at which point there will be a single system runtime and all plug-ins can assume that. This is how things currently work with Objective-C.
In recent years we’ve introduced a new mechanism for plug-ins, based on app extensions. App extension-based plug-ins run in their own process, so there’s no possibility of a conflict like this. It’s not hard to imagine Quick Look moving over to this new architecture.
The Swift runtime issue is well understood and there’s no need for you to take action there. OTOH, if you’d like to file an enhancement request for Quick Look to support the app extension model, I think that’d be valuable.
Share and Enjoy
—
Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware
let myEmail = "eskimo" + "1" + "@apple.com"