Search code examples
objective-cmacoscocoalocationmac-app-store

Set the "Location" value in Network pref pane without using private APIs


Is there a way to programmatically set the "Location" value in the Network preference pane without using private APIs?

I need to do this in a way that will be accepted by the Mac App Store.


Solution

  • AFAIK there's no library function that will reliably achieve this, but you could execute the networksetup tool:

    /usr/sbin/networksetup -switchtolocation $LOCATION
    

    Alas, I’m not sure if this is allowed for MAS apps. The only way to know for sure is as always just trying.