Using Swift with an OS X Preference Pane plugin

隐身守侯 提交于 2019-11-30 12:14:31

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!