I am trying to test changes to my UserDefaults
after using defaults write
on the command line.
If in swift I write:
UserDefaults.standard.set("Hello", forKey:"test")
and on the command line I enter:
defaults read ~/Library/Containers/[app]/Data/Library/Preferences/[app].plist test
where [app]
is my application, the result is correct.
If, how ever, I then enter:
defaults write ~/Library/Containers/[app]/Data/Library/Preferences/[app].plist test "Goodbye"
and in swift:
print("Test: \(UserDefaults.standard.string(forKey: "test"))")
The change seems to be ignored. Using defaults read
does give the new value.
What is missing her?
Running on am iMac with MacOS 10.15.6 and XCode 11.7. I am using sandboxing, and the location was obtained from the SO question Where is a Mac Application's NSUserDefaults Data Stored? .