At the moment I'm using this code
/usr/libexec/PlistBuddy -c "Set PreferenceSpecifiers:1:DefaultValue $productVersion" "Test/Settings.bundle/Root.plist"
in script part of build phase to put product version in a read only field of the application settings. That field has position 1 (starting from 0) of the preferences array.
I'm asking if it's possibile to use something more robust that 1 to access that field since position can be accidentally changed during development by me or by other developers.
Can I access that element specifying it's identifier regardless of its position?
To better explain my needs, I wrote down an example. I need to put something like 1.2.345 into string node of 2nd dict of array ie I need to change from 0.0.0 to 1.2.345. Is it possible to access to dict node without stating that it's the second in the array? I'm asking for something similar to an xpath expression to be used in PlistBuddy (if any exists).
<?xml version="1.0" encoding="UTF-8"?>
<dict>
<key>PreferenceSpecifiers</key>
<array>
<dict>
<key>Title</key>
<string>Application info</string>
<key>Type</key>
<string>PSGroupSpecifier</string>
</dict>
<dict>
<key>DefaultValue</key>
<string>0.0.0</string>
<key>Key</key>
<string>version</string>
<key>Title</key>
<string>Version</string>
<key>Type</key>
<string>PSTitleValueSpecifier</string>
</dict>
<dict>
<key>DefaultValue</key>
<string>0</string>
<key>Key</key>
<string>build</string>
<key>Title</key>
<string>Build</string>
<key>Type</key>
<string>PSTitleValueSpecifier</string>
</dict>
...