Wrapper around Property List Util to Convert between XML1 & BINARY1 formats

Xcode Property List Converting Formats Binary to XML

Ever found you had to change the value of Disque Dur Vierge in the French resource of        SystemUIServer.app? No? Good. If so, this small wrapper may help. The normal procedure is to locate the string in the resource, (no linting here, create a backup before touching these files!) convert it from “Apple binary property list” (pass binary1 as arg to –convert flag on plutil) to “XML Document text” (argument you pass plutil is xml1 instead), go at it with your editor of choice, save and convert back to binary1. Then send a TERM signal to SystemUIServer (via killall) to restart and see your changes. If this paragraph is confusing or you’re interesting in learning this stuff more, refer to my last post, WTF is a “command” or “passing arguments”? Making Sense of the Command Line.



 Manually (old fashioned way)


pushd /System/Library/CoreServices/SystemUIServer.app/Contents/Resources/French.lproj/
sudo plutil -convert xml1 InfoPlist.strings
sudo vi InfoPlist.strings
sudo plutil -convert binary1 InfoPlist.strings

With this property list format helper script

(code pasted below) placed in ~/bin (create if it doesn’t exist) which is in my ~/.PATH (create if it doesn’t exist) that’s sourced in my ~/.zshrc or ~/.bashrc etc.

Script Usage

sudo update-plist.sh InfoPlist

down to 1 line from 5 and 1 sudo from 3, respectively.

or (if script not in $PATH)

cd ~/Downloads
sudo ./update-plist.sh InfoPlist

Troubleshooting: You may want to set the executable flag on owner (o+x) on the script. May need to prefix with sudo or run in su

The Code, pasted from the GitHub Gist

# A script to make it easier to edit resources in mac.apps on the commandline
# Isam M 2015 <http://github.com/lsd/update-plist.sh>

# exit if pipeline (1+ cmd) fails
set -e

echo "USAGE (default English): To open ScreenCapture.strings in SystemUIServer.app/C/R/English.lproj
echo "$ sudo update-plist.sh ScreenCapture

# hardcode English ...


# cd in, validate resource, make backup
pushd "$DIR"
ls -l
diff "$RESOURCE" "$RESOURCE" 2>/dev/null
BACK=~/".$RESOURCE.binary1.`date -j +%S%s`.back"
echo "Backed up resource $RESOURCE to $BACK"

# Convert to XML, open in vi, when done convert back to binary
sudo plutil -convert xml1 "$RESOURCE"
sudo vi "$RESOURCE"
sudo plutil -convert binary1 "$RESOURCE"

# Clean up
mv "$BACK" /tmp
echo "Restart SystemUIServer? (ctrl+c to cancel)" && read
killall SystemUIServer

* See latest revision at gist.github.com/lsd: Wrapper around `plutil` to quickly jump between xml1 and binary1 when editing plists