Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to force reload preference plist for an app in OS X?

My swift program periodically updates the com.google.Chrome.plist file stored in /Library/Preferences.

During the initial executions, it just needs a restart of Chrome browser for the policies to take effect. But now I need to restart the system to make the policies to take effect. How do I get it to update without restarting the Mac?

And also the Reload policies button in chrome://policy won't do the trick. (I wonder what's its purpose?)

And also, please explain the difference between placing the plist file in /Library/Preferences and in /Library/Managed Preferences

Or is there any command for OS X, like gpupdate /force (for windows) as they said here.

I also recently found that this problem persists for other apps too ( I tried editing the plist file of Safari from ~/Library/Preferences/com.apple.Safari.plist and it requires a system reboot to take effect )

I'm stuck here for long. A nudge in the possible direction would do too!

Thank you!

like image 325
Goutham Ganesan Avatar asked Jul 03 '18 11:07

Goutham Ganesan


People also ask

How do I open plist files on OSX?

plist - The primary property list for Mac OS X applications, located in the /​Contents/​ directory of an . APP bundle. To view this file, right-click an application file, select "Show Package Contents," and open the Contents folder.

What does plist do on Mac?

Preference and configuration files in macOS use property lists (plists) to specify the attributes, or properties, of an app or process. An example is the preferences plist for the Finder in the Library/Preferences/ folder of a user's home folder. The file is named com. apple.

Where is com Apple Systempreferences plist?

They are stored in ~/Library/Preferences/com. apple. systempreferences. plist.


1 Answers

The reason is, from Mac OS Mavericks, apple started to cache plist files, which results in replacing a plist file manually has no effect until the cache is reloaded automatically. If you open the application which uses this plist file to early, it overwrites your copied file with the old/cached one.

To reload the preference file manually, use defaults read <filename>.plist to read the new plist values.

Source: nethack

Now, I just use a sh script to call the defaults after executing my program.

like image 170
Goutham Ganesan Avatar answered Sep 27 '22 21:09

Goutham Ganesan