I tried updating the proxy settings of my mac. SCDynamicStoreSetValue: returned false, indicating an unsuccessful update. This is the code I use. What is the correct way?
let ds: SCDynamicStoreRef = SCDynamicStoreCreate(nil, "setProxy" as CFString, nil, nil)!
let isUpdated = SCDynamicStoreSetValue(ds, "HTTPProxy" as CFStringRef, "111.111.111.1")
if isUpdated{
print("updated")
}else{
print("not updated")
}
The question is about why SCDynamicStoreSetValue returns false and how to circumvent it.
After
SCDynamicStoreSetValuefails, callSCError()to obtain the error code:Or obtain the error as a string with:
In either case, review the Status and Error Codes for the System Configuration Framework. That should provide you with the reason that
SCDynamicStoreSetValueis returning false.(If your app is Sandboxed, the likely reason is
kSCStatusAccessError, or "Permission Denied". Sandboxed apps can't set those values.)