Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MacOSX screensaver not loading due to Library not loaded: @rpath/libswiftAppKit.dylib

We have a working Mac OS X screensaver as a standalone Xcode project, but we needed to have it as a target in another Xcode project that also contains a related app.

I added a target for a screensaver, copied the code, added to that target, etc, etc. The code is the same one that works in the other screensaver, but on this one, it generates the following error:

2015-03-10 09:43:24.766 System Preferences[32495]: Error loading /Users/pupeno/Library/Screen Savers/Ninja.saver/Contents/MacOS/Ninja:  dlopen(/Users/pupeno/Library/Screen Savers/Ninja.saver/Contents/MacOS/Ninja, 265): Library not loaded: @rpath/libswiftAppKit.dylib
  Referenced from: /Users/pupeno/Library/Screen Savers/Ninja.saver/Contents/MacOS/Ninja
  Reason: image not found
2015-03-10 09:43:24.766 System Preferences[32495]: ScreenSaverModules: can't get principalClass for /Users/pupeno/Library/Screen Savers/Ninja.saver

The library in question is definitely there:

$ ls -w1 Library/Screen\ Savers/Ninja.saver/Contents/Frameworks/
libswiftAppKit.dylib
libswiftCore.dylib
libswiftCoreGraphics.dylib
libswiftDarwin.dylib
libswiftDispatch.dylib
libswiftFoundation.dylib
libswiftObjectiveC.dylib
libswiftQuartzCore.dylib
libswiftSecurity.dylib

Any ideas what might be causing this?

like image 516
pupeno Avatar asked Mar 10 '15 09:03

pupeno


2 Answers

The problem was that the Runpath Search Path, for some reason, in this new target, was blank. I fixed this problem by adding this:

@executable_path/../Frameworks @loader_path/../Frameworks

to it (which I took from the working screensaver configuration). This is how it looks like:

enter image description here

like image 166
pupeno Avatar answered Oct 09 '22 04:10

pupeno


Like Pablo said, you need the following as your Runtime Search Path:

@executable_path/../Frameworks @loader_path/../Frameworks

This should be the default. Make sure it's there though. You also need to set Embedded Content Contains Swift Code to YES if you're using Swift. That took me awhile to figure out.

(Xcode should totally infer this. Oh well. I filed a radar for this awhile.)

like image 32
Sam Soffes Avatar answered Oct 09 '22 03:10

Sam Soffes