User Defaults and Data Protection

I was unable to find this stated explicitly in the documentation, but given that an app's preferences seem to be stored inside the sandbox (as Preferences/<CFBundleIdentifier>.plist) does setting the com.apple.developer.default-data-protection entitlement affect those preferences as well?

Answered by DTS Engineer in 917334022
Written by jzilske in 858122021

does setting the com.apple.developer.default-data-protection entitlement affect those preferences as well?

Yes. But it’s not always obvious because of the way that default data protection is inherited.

My general advice is that you never set com.apple.developer.default-data-protection, but instead explicitly set the data protection on the files and directories that you want to protected.

If you have previously set it in the past and want to undo that choice, things get… complex )-:

Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Accepted Answer
Written by jzilske in 858122021

does setting the com.apple.developer.default-data-protection entitlement affect those preferences as well?

Yes. But it’s not always obvious because of the way that default data protection is inherited.

My general advice is that you never set com.apple.developer.default-data-protection, but instead explicitly set the data protection on the files and directories that you want to protected.

If you have previously set it in the past and want to undo that choice, things get… complex )-:

Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Follow-up question: What about shared preferences in an app group’s shared user defaults database? I suppose those are not affected by the default-data-protection entitlement. Correct?

Written by jzilske in 917388022

I suppose those are not affected by the default-data-protection entitlement.

Correct. AFAIK there’s no way to change the default data protection on the app group container (thank goodness!).

Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"