I'd like to change the 'bundle-identifier' string value in a plist file using the command line. Using 'defaults', how would I do this?
FYI here is the plist in its entirety:
<?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"> <dict> <key>items</key> <array> <dict> <key>assets</key> <array> <dict> <key>kind</key> <string>software-package</string> <key>url</key> <string>http://eventpilotadmin.com/doc/clients/ISES/Eventworld2011/proofs/iphone_Eventworld2011_proof.ipa</string> </dict> </array> <key>metadata</key> <dict> <key>bundle-identifier</key> <string>com.ativsoftware.Eventworld2011</string> <key>bundle-version</key> <string>1.0</string> <key>kind</key> <string>software</string> <key>title</key> <string>Eventworld2011</string> </dict> </dict> </array> </dict> </plist>
plist file. If you need to edit these items, Control-click (or right-click) Info. plist in the sidebar and select Edit Manually. This allows you to add or edit items in raw XML format.
Open it and inside, there should be at least one Plist file called info. plist. Right-click it and select Open With>Xcode. The file will open in Xcode and you can edit the already existing rows of preferences.
Using The FinderSelect the plist file in the Finder and doing File > Get Info. At the bottom of the file info window you'll see a section called Sharing & Permissions. You want to make sure you're in that list and that you have Read & Write level access to the file.
Try this:
/usr/libexec/PlistBuddy -c "Set :items:0:metadata:bundle-identifier newidentifier" your.plist
If the line format is consistent you could do it with sed
like this:
sed -n '/bundle-identifier/{p;n;s/>.*</>new value</;};p' your.plist
In your example this would change com.ativsoftware.Eventworld2011
to new value
Add -i
to edit in place.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With