5

So here's my current problem. I'm attempting to create a screensaver, all I'm doing is setting a background color like so,

public override func drawRect(rect: NSRect) {

    super.drawRect(rect)

    let color = NSColor(red:0.33, green:0.78, blue:0.99, alpha:1)

    color.setFill()
    NSBezierPath.fillRect(rect)

}

Fairly straight forward. I also set EMBEDDED_CONTENT_CONTAINS_SWIFT = YES;

Now when I go to install the .saver file I am returned with a message that says

You cannot use the screensaver X with this version of OS X

Any ideas?

luk2302
  • 55,258
  • 23
  • 97
  • 137
Idris
  • 1,658
  • 4
  • 16
  • 21
  • I'm running into this to - I managed to get it working once, but it seems like every timeI make a small change to my code I am back to square one. – Mike Bedar Feb 24 '16 at 17:26
  • Pop open the Console to see what the error message is being reported from System Preferences. – voidref Mar 13 '16 at 03:49

2 Answers2

4

If you're on Mojave, then the Principal class needs to include the module name (target name) as well:

<key>NSPrincipalClass</key>
<string>[YourTarget].[YourClass]</string>

You might also need to set Always Embed Swift Standard Libraries to YES in your Build Settings as well as check the Principle Class as above.

Sources:

https://github.com/JohnCoates/Aerial/issues/464 https://blog.viacom.tech/2016/06/27/making-a-macos-screen-saver-in-swift-with-scenekit/

svarrall
  • 8,545
  • 2
  • 27
  • 32
1

This will happen if the Principle Class in the Info.plist is set incorrectly, or even if it has a case mismatch from the actual class name. (If the class name is "MYCoolSaverView" but the Info.plist thinks the class name is "mYCoolSaverView" the .saver bundle will compile correctly, but you'll see this error when you try to run it under System Preferences.)

Gary W. Longsine
  • 642
  • 9
  • 12