views:

443

answers:

4

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

/System/Library/Frameworks/ScreenSaver.framework/Versions/A/Resources/ScreenSaverEngine.app

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.

+1  A: 

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

edit:

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

cobbal
I was trying to avoid this only because of the lack of availability of another machine...
Dave Martorana
A: 

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.

Peter N Lewis
+2  A: 

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.

Mark Thalman
Fantastic link! I don't know why I couldn't find it myself :)
Dave Martorana
A: 

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.

Gavin Maclean