com.apple.dock.plist is changed in macOS14.0 and later

Hi there, Currently, we are working on the enterprise project that using data in ~/Library/Preferences/com.apple.dock.plist to get detail design of the original Dock (as autohide, orientation).

It still has been worked until macOS 13.* as description as below:

But, It has been changed in macOS 14.*

Is there any alternative method to do that in macOS 14.* and later?

Accepted Reply

Unless otherwise documented, system preferences files are not considered API. Relying on them incurs a significant binary compatibility risk. Moreover, when you do run into such problems there may be no path forward. Apple tries to provide a path ford when we change APIs, but we can’t do that for preferences files.

In short, don’t start down that path!

Sadly, it seems that you’re already on that path )-: In this case I think there might be a way forward for you. The Dock has an AppleScript interface that allows you read (at least some of) its preferences. For example:

tell application "System Events"
	autohide of dock preferences
end tell

You should experiment to see if this is sufficient to accomplish your goals. If so, you can run this script — or the equivalent Apple events — from your app to get the same values.

IMPORTANT This will trigger a TCC alert, so only do this from a context where that alert makes sense.

Share and Enjoy

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

Replies

Unless otherwise documented, system preferences files are not considered API. Relying on them incurs a significant binary compatibility risk. Moreover, when you do run into such problems there may be no path forward. Apple tries to provide a path ford when we change APIs, but we can’t do that for preferences files.

In short, don’t start down that path!

Sadly, it seems that you’re already on that path )-: In this case I think there might be a way forward for you. The Dock has an AppleScript interface that allows you read (at least some of) its preferences. For example:

tell application "System Events"
	autohide of dock preferences
end tell

You should experiment to see if this is sufficient to accomplish your goals. If so, you can run this script — or the equivalent Apple events — from your app to get the same values.

IMPORTANT This will trigger a TCC alert, so only do this from a context where that alert makes sense.

Share and Enjoy

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

Dear @eskimo,

I got your point, and I'm going to change my mindset with the alternative solution below: I have tried to use the UserDefault to get its information (dock orientation) :

 if let defaults = UserDefaults(suiteName: "com.apple.dock"),
           let orientation = defaults.string(forKey: "orientation")

But It is not reliable. Sometimes It got, sometime it didn't.

I have double-checked with the Terminal:

[Restored 1 Mar 2024 at 09:06:03]
(base) macos ~ % defaults read com.apple.dock
{
    "mod-count" = 1035;
}
(base) macos ~ % defaults read com.apple.dock autohide
2024-03-01 09:07:28.641 defaults[24181:525841] 
The domain/default pair of (com.apple.dock, autohide) does not exist
(base) macos ~ % defaults read com.apple.dock         
{
    mineffect = genie;
    "mod-count" = 1040;
    orientation = bottom;
}
(base) macos ~ % defaults read com.apple.dock autohide
2024-03-04 10:13:44.931 defaults[38656:1061252] 
The domain/default pair of (com.apple.dock, autohide) does not exist

I expect not to use scripts as little as possible.

I have tried to use the UserDefaults to get its information

UserDefaults is better than reading the property list directly, but it still has the same fundamental problem: Unless otherwise documented, the domain, keys, and values for Apple preferences are implementation details, not API.

Share and Enjoy

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