I have developed an sandboxing app. One of its features is to make some changes to the /Users/username/Library/Preferences com.apple.finder.plist. So in order to do so, I have added the following to my entitlement.plist:
<key>com.apple.security.temporary-exception.shared-preference.read-write</key>
<array>
<string>com.apple.finder</string>
</array>
<key>com.apple.security.temporary-exception.apple-events</key>
<array>
<string>com.apple.finder</string>
<string>com.apple.systemevents</string>
</array>
My app works perfectly fine if I turn off sandboxing, however, if I enable sandboxing, sometimes my app works but most of the time my apps doesn't work.
What I did was, 1. I used NSAppleScript to make changes to the finder.plist, then 2. tell "finder" to quit and relaunch again. the "quit" and relaunch part works perfectly fine:
tell application "Finder" to quit
set inTime to current date
repeat
tell application "System Events"
if "Finder" is not in (get name of processes) then exit repeat
end tell
if (current date) - inTime is greater than 10 then exit repeat
delay 0.2
end repeat
tell application "Finder" to activate
(from How to relaunch finder application)
however the changing finder.plist doesn't always seems to work. (no error) But if I turn off sandboxing, it works.
So my conclusion is, sandboxing breaks my code, but I really don't know how to fix this, because I have already added the entitlement?