Animate screen savers, and interact with the screen saver infrastructure. Use functions that help you produce random values and centering rectangles.


The Screen Saver framework defines the interface for subclasses to interact with the Screen Effects user interface feature. Screen Effects modules need to be written in Objective-C with their user interface implemented using Cocoa.

Screen Saver Framework Classes

The Screen Saver framework consists of the ScreenSaverView class, an abstract subclass of NSView. ScreenSaverView defines an interface for animating screen savers, instantiating small preview versions of the screen saver view (for display in the system preferences, for example), and for providing a configuration sheet to set various properties of the screen saver.

The ScreenSaverDefaults class is a subclass of UserDefaults and provides an interface to the standard user preferences storage system.

In addition, the Screen Saver framework provides a number of functions commonly required by screen saver applications including producing random values and centering rectangles.

Call Order

When macOS starts your screen saver, the following things happen:

  1. The screen fades to black.

  2. Your module is instantiated and its init(frame:isPreview:) routine is called.

  3. The window is created.

  4. Your module is installed in the window.

  5. Your window is activated and its order is set. The draw(_:) call is called at this point.

  6. The screen fades in, revealing your window in the front.

  7. Your startAnimation() method is called. This method should not do any drawing.

  8. Drawing continues. Your animateOneFrame() is called repeatedly.

  9. The user takes some action.

  10. Your stopAnimation() method is called.

Binary Compatibility

Because screen savers are plug-ins for the screen saver engine, a screen saver can only be supported if its binary contains a slice for the architecture of the running engine. As with any application, the screen saver engine normally runs using the most recent architecture supported by a given computer (assuming that the engine has a slice for that architecture).

For full compatibility, a screen saver must contain (at least) an i386 slice (compiled for the oldest OS version you wish to support) and an x86_64 slice (compiled for version 10.6 and later).



class ScreenSaverView

An abstract class that defines the interface for subclassers to interact with the screen saver infrastructure.

class ScreenSaverDefaults

A class that defines a set of methods for saving and restoring user defaults for screen savers.


Screen Saver Functions

Functions and function-like macros available in the Screen Saver framework.