I\'d like to use Swift to build an OS X Preference Pane plugin for the System Preferences app, but I can\'t get it to work.
After clicking \"Next\" the Xcod
First, you need to enable the "Embedded Content Contains Swift" setting so that Xcode will copy the necessary Swift libraries into the bundle.
Then, you get this error:
System Preferences[68872]: dlopen_preflight failed with dlopen_preflight(/.../preftest.prefPane/Contents/MacOS/preftest): Library not loaded: @rpath/libswiftAppKit.dylib Referenced from: /.../preftest.prefPane/Contents/MacOS/preftest Reason: image not found for /.../preftest.prefPane
This means the app doesn't know where to load the included Swift libraries from.
To fix this, add @loader_path/../Frameworks
to the runpath search paths in the build settings, telling it that the Swift libraries are in the Frameworks directory of your prefpane:
See the dyld man page for further info about dynamic loading.
There was an Apple bug introduced with macOS High Sierra. This bug is now resolved in the latest dot release of macOS. See https://github.com/klaas/QlaasSwiftPreferencesPane for a working sample project.