Take the 2-minute tour ×

I was wondering if there was any decent way, other than NSLog-ing just about everything - to properly debug a Screensaver app bundle in OS X?

The "Screensaver" is a project type in XCode, but there's obviously no Build and Go debugging. Further, I've found that in fact my bundle is getting loaded in to the


application as some sort of plugin.

So is there a decent way to debug your code? Looking at crash reports and NSLog-ing to the console helps, but it's far from perfect.

share|improve this question
add comment

6 Answers

up vote 5 down vote accepted

There is an old MacTech article that describes the Screen Saver development cycle. There is also a Part 2 to the article. Look in the "Debugging Tips" section.

I find this method a pain so I wrote an application, the basic application was one window and a controller that initialized a ScreenSaverView with my new screensaver bundle. Once that was working all I had to do to test a change was hit Command-R in Xcode.

share|improve this answer
Fantastic link! I don't know why I couldn't find it myself :) –  Dave Martorana Jul 11 '09 at 2:22
Kuto's to David Hill for that article (x-Apple DTS!) –  geowar May 16 '12 at 6:16
That article is from when MacTech was worth reading for developers. I unsubscribed when they switched their focus to IT. –  Mark Thalman May 16 '12 at 12:29
I'd love if anyone can post updated steps, because latest xcode are quite different to set up :/ –  Tom Roggero Aug 20 '12 at 2:29
add comment

You can debug plugins by executing the application that will load the plugin.

So to debug a screensaver, open your plugin project, choose New Custom Executable from the Project menu and set the application to be the screensaver engine.

For debugging a screensaver, you might also want to use a second Mac and use remote debugging so your user interface actions don't interfere with the screensaver.

share|improve this answer
On Lion with XCode4, I found this was done by changing the executable of the scheme to /System/Frameworks/ScreenSaver.framework/Resources/ScreenSaverEngine.app –  iforce2d Jan 6 '12 at 14:06
I also found you still need to install the screensaver into the system preferences as usual each time you change it, but that's still a darn sight better than waiting 3 minutes every time. –  iforce2d Jan 6 '12 at 14:14
>>> can't format text here; move to new answer <<< –  geowar Feb 12 '12 at 2:26
Instead of remote debugging you can pass "-background" as a command line argument to the ScreenSaverEngine to have it run as your desktop… –  geowar May 16 '12 at 6:15
add comment

There's a few Mac OS X apps that will run screen savers: SaverLab, Screenalicious, etc. Just find one of them on the web and download it and then set it as the target executable (as Peter N Lewis said).

To avoid copying the build product to '~/Library/Screen Savers/' after each build you can add a custom build script (note: I'm using '/bin/tcsh -x' for the shell):

#remove the old screen saver or link

#if this is a debug build…
if ("${CONFIGURATION}" == "Debug" ) then

# create a symbolic link from our screen saver to this users screen saver directory

#if this is a release build…
else if ("${CONFIGURATION}" == "Release" ) then

# copy our screen saver to this users CMM directory


Then set its input file to "${BUILT_PRODUCTS_DIR}/${FULL_PRODUCT_NAME}" and its output file to "${HOME}/Library/Screen Savers/${FULL_PRODUCT_NAME}".

Now when you build / run your project it will auto-magicly link to your debug build or copy your release build.

share|improve this answer
add comment

not necessarily the best way, but you could ssh in from another machine and launch ScreenSaverEngine from gdb (untested)


also, you could try adding a new application target and add your ScreenSaverView to a window in IB, you may have to manually configure stuff like settings, but it could help some and should probably work OK as ScreenSaverView is a subclass of NSView

share|improve this answer
I was trying to avoid this only because of the lack of availability of another machine... –  Dave Martorana Jul 9 '09 at 5:45
add comment

As Peter says, you can debug the plugin by executing an application that will load the plugin.

However, rather than using the screensaver engine you could also use system preferences. When the preferences appear navigate to your screensaver under "Desktop & Screen Saver" to load your plugin.

It's not perfect as your view won't be full size, but it can be easier than setting up remote debugging.

share|improve this answer
I've been using this method. Works great for my purposes. –  Rob Segal Sep 4 '12 at 2:36
add comment

You could also make the screensaver engine ('/System/Library/Frameworks/ScreenSaver.framework/Resources/ScreenSaverEngine.app') the target executable and pass it the -background flag (so it runs behind everything instead of in front of everything).

share|improve this answer
add comment

Your Answer


