I am trying to read the currently playing track of iTunes using ScriptingBridge. I found a couple of other threads here but no one seems to be working for me (macOS Mojave a
The solution provided by matt works.
I noticed that the sandboxing feature can still be enabled, if I add the following key to the entitlements file:
<key>com.apple.security.temporary-exception.apple-events</key>
<array>
<string>com.apple.iTunes</string>
</array>
The key thing is that you must at some point see the dialog that says
MyApp wants access to control “iTunes“. Allowing control will provide access to documents and data in “iTunes“, and to perform actions within that app.
If you have not seen that dialog:
In the Entitlements, turn sandboxing off.
In the Info.plist, add a Privacy - AppleEvents Sending Usage Description entry with some arbitrary string as its value.
Run the app. If it still doesn't work, then say this in the Terminal:
tccutil reset AppleEvents
and run the app again.