Post

Replies

Boosts

Views

Activity

Reply to macOS & NSUserDefaults
Have you done any hacking around on preferences? Is the a sandbox build? Yes, I did. 😞 I wanted to reset my preferences to factory defaults and thought that I could do that quickly by deleting the preferences file from my application preferences in the ~/Library/Containers directory. After deleting the file, I started to get the same log errors as described in this thread, and my application would not properly initialize to its default preference values. I tried the usual clean build and then deleting the sandboxed application entirely from the ~/Library/Containers directory, but neither helped. The log errors persisted. I then tried the simplest thing that came to mind, I created an empty preferences file with touch com.example.MyApp.plist in ~/Library/Containers/com.example.MyApp/Data/Library/Preferences directory and made the file read/write by owner only chmod 600 com.example.MyApp.plist. Running in Xcode the application is initializing default preference values properly and the log errors have stopped. I did not restart my Mac and I did not have to killall prefsd. I learned a valuable lesson, don't do any hacking around on the preferences.
Mar ’22