Editing plist file using shell script

user2653062 picture user2653062 · Oct 5, 2014 · Viewed 15.6k times · Source

I have used pkgbuild to create a default Component Property List file. The file looks like:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-     1.0.dtd">
<plist version="1.0">
<array>
    <dict>
        <key>BundleHasStrictIdentifier</key>
        <true/>
        <key>BundleIsRelocatable</key>
        <true/>
        <key>BundleIsVersionChecked</key>
        <true/>
        <key>BundleOverwriteAction</key>
        <string>upgrade</string>
        <key>RootRelativeBundlePath</key>
        <string>MyApp.app</string>
    </dict>
</array>
</plist>

I want to modify this file by using shell script. I tried using defaults write but it didn't do anything.

What is the way to do it?(For example: I want to set BundleIsRelocatable to false)

Answer

jm666 picture jm666 · Oct 5, 2014

Also:

plutil -replace BundleIsRelocatable -bool false plistfilename.plist