简体   繁体   中英

Cocoa Screensaver plugin with bundled custom frameworks

My app is partitioned into a number of frameworks.
Each framework has its Installation Directory set to @executable_path/../Frameworks , is linked and copied to the main executables Frameworks folder. All is working great.

Now some of the same frameworks are used in a separate screen saver executable.

The frameworks are linked, copied, present in the actual binary -
yet the screensaver module will fail to load with the following error:

Error loading /Users/someuser/Library/Screen Savers/MyScreenSaver.saver/Contents/MacOS/MyScreenSaver:  dlopen(/Users/someuser/Library/Screen Savers/MyScreenSaver.saver/Contents/MacOS/MyScreenSaver, 265): Library not loaded: @executable_path/../Frameworks/BusinessBase.framework/Versions/A/BusinessBase
  Referenced from: /Users/someuser/Library/Screen Savers/MyScreenSaver.saver/Contents/MacOS/MyScreenSaver
  Reason: image not found

Looks like the screen saver (loaded as a plugin) cannot find the frameworks referenced by itself.

I've tried setting the screen savers Framework Search Path to both @loader_path/../Frameworks and @executable_path/../Frameworks .
No luck.

Any ideas what else to try..?

FWIW I've managed to fix this issue with some install_name_tool magic in a post build script:

The key was to change executable_path to loader_path and use the correct relative paths for the binary calling the respective framework.

For a screensaver plugin, @executable_path is the path to the ScreenSaverEngine executable that's loading your screensaver, or to System Preferences if it's running as a preview. It is not the path to your screensaver module! For that, you will need to use @loader_path .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM