Hi fellow Apple developers,
I store machine level setting of my app under
/Library/Preferences/<plist file>
. And I use CFPreferencesCopyValue(<key>, <bundle>, kCFPreferencesAnyUser, kCFPreferencesAnyHost)
to read the value. According to https://stackoverflow.com/questions/46575892/cfpreferences-any-host-and-any-application-domain-behavior, kCFPreferencesCurrentHost
domain corresponds to a plist file stored under a ByHost
directory. So I thought using kCFPreferencesAnyHost
domain makes sense here and it works fine under Sierra (10.12.6) macOS SDK 10.12.However, the same
CFPreferencesCopyValue
call under El Capitan (10.11.6) macOS SDK 10.12 does not get the value. But it works when I change kCFPreferencesAnyHost
to kCFPreferencesCurrentHost
.What's more strange is on Sierra, using either
kCFPreferencesAnyHost
or kCFPreferencesCurrentHost
gets the correct result. Under the documentation of CFPreferencesCopyValue, it says "the call searches on the exact domain specified". So that means the path of /Library/Preferences/<plist file>
can be mapped to both current host and any host domains on Sierra, but only current host domain on El Capitan. Is my understanding correct?Where can I potentially find a documentation about this change? I took a look at the release notes of Sierra but did not find anything about this. Maybe this change is too minor to be noted? My app runs on multiple versions of macOS so it will be good to know the change instead of relying on self-experimentation (or maybe this is the only way).
This is basically a copy with few tweaks from https://stackoverflow.com/questions/48917768/preferences-domain-behaves-differently-on-el-capitan-and-sierra.