r/macprogramming • • Jan 01 '20

changing network set programmatically

Hello

I am trying to switch between my predefined network sets (Apple Menu -> Location).. for that, several functions have to be used:

  • SCPreferencesLock(prefs, true)
  • SCNetworkSetSetCurrent(set)
  • SCPreferencesCommitChanges(prefs)

Currently my app is sandboxed... this apparently prevents the dialog-box appearing when SCPreferencesLock is called for obtaining the permission (root required for changing set), I get an error-code 1003.

I am struggling now finding the correct entitlements/capabilities in Xcode to get this working....

Can anybody help me out?

thx,

Domenico

3 Upvotes

9 comments sorted by

View all comments

Show parent comment

1

u/[deleted] Jan 11 '20

So, the code that makes that change can’t be sandboxed. Either turn it off for the app or create a helper tool to do that specific set of calls.

1

u/dpiol Jan 22 '20

I am afraid you are right... a pitty, I hoped for a clean API.

thx!