The app was rejected and I need to found a way to write this value in a sandbox app.
While your app was rejected for a technical reason, there’s an underlying policy issue here. Sandboxed apps are not allowed to make changes that affect the system as a whole, and that includes this preference. If you found a way around the sandbox restriction, it would be considered a security vulnerability.
You have a couple of options here:
You can use a non-sandboxed app, distributed outside of the Mac App Store under the aegis of the Developer ID programme.
You can file an enhancement request for a sandbox-compatible way to do this task. There are lots of places where sandboxed apps are allowed to make global changes like this, but such changes are always mediated by the system (often based on user authorisation) and thus need a dedicated API (as opposed to the very general
Note If you do the latter, please post your bug number, just for the record.
Also, there’s nothing stopping you doing both of these.
Share and Enjoy
Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware
let myEmail = "eskimo" + "1" + "@apple.com"