In my Info.plist
file I want to modify a Plist file on the shell which looks like this:
<plist version="1.0">
<dict>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLName</key>
<string>urlname-1</string>
</dict>
</array>
</dict>
</plist>
Now I want to make it look like this using PlistBuddy, adding the CFBundleURLSchemes
key with a string-array value (or every other value):
<plist version="1.0">
<dict>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLName</key>
<string>urlname-1</string>
<key>CFBundleURLSchemes</key>
<array>
<string>urlscheme-1</string>
</array>
</dict>
</array>
</dict>
</plist>
How can I achieve this with PlistBuddy?
Assumed the array value of CFBundleURLTypes
would be empty:
By executing /usr/libexec/PlistBuddy -c "Add :CFBundleURLTypes:0:CFBundleURLName string 'urlname-1'" Info.plist
I'm able to add the dictionary into the array including it's first key/value pair:
<plist version="1.0">
<dict>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLName</key>
<string>urlname-1</string>
</dict>
</array>
</dict>
</plist>
But I don't know how to get the second key, eg CFBundleURLSchemes
with a string-array value into the same dictionary.
Can anyone give me a pointer? Is this possible with PlistBuddy at all?