Using Swift with an OS X Preference Pane plugin

前端 未结 2 568
一个人的身影
一个人的身影 2021-01-02 02:49

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

相关标签:
2条回答
  • 2021-01-02 03:32

    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.

    0 讨论(0)
  • 2021-01-02 03:36

    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.

    0 讨论(0)
提交回复
热议问题