6 Replies
      Latest reply on Feb 15, 2019 9:54 AM by sjmills
      sjmills Level 1 Level 1 (0 points)

        I've tried everything I could find for getting permission to send AppleScripts to iTunes from my screensaver;

        -Added NSAppleEventsUsageDescription string to info.plist.

        -Added this to info.plist:









        -Asked if I had permission:

        NSAppleEventDescriptor* targetAppEventDescriptor = [NSAppleEventDescriptor descriptorWithBundleIdentifier:@"com.apple.iTunes"];

        OSStatus status = AEDeterminePermissionToAutomateTarget(targetAppEventDescriptor.aeDesc, typeWildCard, typeWildCard, true);

        Which returns errAEEventNotPermitted (-1743).


        Is there any way to configure my screensaver to work around the stupid security stuff that continually gets in developers' way?

        • Re: Permission to send AppleScripts to iTunes from screensaver
          eskimo Apple Staff Apple Staff (11,625 points)

          com.apple.security.temporary-exception.scripting-targets is an entitlement, which means it doesn’t go into your Info.plist but rather into your code signing entitlements.

          However, this won’t fix your problem because entitlements apply on a process-by-process basis.  Screen savers use the old school bundle-based plug-in mechanism, which means that they are loaded within a system process.  Thus, the entitlements applied to your screen saver are irrelevant.  What matters is the entitlements of the host process and, as that’s a system process, you can’t change that.

          Short term you may be able to get around this using an IPC mechanism to communicate to another process (a launchd agent, perhaps) that can have its own entitlements, and thus can use Apple events.

          Long term the best solution to this problem would be for screen saver to supports the app extension plug-in model, where your code runs in a separate process and thus can have its own entitlements.  I encourage you to file an enhancement request for that, making sure to describe your specific requirements.

          Please post your bug number, just for the record.

          Share and Enjoy

          Quinn “The Eskimo!”
          Apple Developer Relations, Developer Technical Support, Core OS/Hardware
          let myEmail = "eskimo" + "1" + "@apple.com"

            • Re: Permission to send AppleScripts to iTunes from screensaver
              sjmills Level 1 Level 1 (0 points)

              Yes, I was hoping there was some way I hadn't found to add entitlements to a screensaver. I guess I'll have to do without and let my screensaver be lame for now. *****.


              I've submitted radar://48099639


              Along with requesting app extension plugins for screensavers, I also suggested extenting NSDistributedNotificationCenter to be a "requester observer" using a new method -(void) addRequesterObserver:(id)obj name:(NSString*)name;, so iTunes would listen for requests to post its @"com.apple.iTunes.playerInfo" notification. An observer of that notification would request it, iTunes would get the request, which in turn out post the notification, so my screensaver would then get the notification without having to wait for iTunes to start playing the next track. Roundabout? Yes, but still a lot more straightforward than monkeying with entitlements and a wrapper app for the plugin.


              But, being able to distribute screensavers in a wrapper app would then finally let us sell them on the App Store. I'm sure that would make tons of developers happy.


              Now if they'd just fix this forum code so it doesn't totally distroy all our typing when we hit Undo and then never put it back with Redo. Yep, I had to retype about 80% of this.