23

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>
kevmalek
  • 1,373
  • 2
  • 12
  • 13
  • Better delete this and ask the question at [`Ask Different`](http://apple.stackexchange.com/) before you get down votes. – Lenar Hoyt Aug 12 '11 at 18:47
  • 2
    It's more like coding, I voted up and it seems that I am not the only one :) – sorin Aug 27 '13 at 14:54

4 Answers4

35

Try this:

/usr/libexec/PlistBuddy -c "Set :items:0:metadata:bundle-identifier newidentifier" your.plist
user478681
  • 8,330
  • 4
  • 26
  • 34
5

@user478681's answer did not work for me, because of the missing step to unzip and zip the ipa file.

I found a site with those steps.

In short:

unzip app.ipa
/usr/libexec/PlistBuddy -c "Set :CFBundleIdentifier newidentifier" Payload/MyApp.app/Info.plist
zip -qr ResignedApp.ipa Payload

If you need to resign your app, follow the instructions on the aforementioned site.

Jon
  • 7,848
  • 1
  • 40
  • 41
5

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.

sorpigal
  • 25,504
  • 8
  • 57
  • 75
0

Updated version:

/usr/libexec/PlistBuddy -c "set :CFBundleIdentifier newidentifier" your.plist
user2643679
  • 706
  • 12
  • 18