5

I am making my own application and I would like to change some values in my Info.plist file using terminal.

I have tried doing defaults write Info.plist CFBundleExecutable -string <Executable> and defaults write Info.plist CFBundleExecutable <Executable> however it never seems to work. I don't get any output so I don't even know what it is i'm doing wrong.

Thanks for the help

  • 2
    Can You try absolute path to Your Info.plist file? It works for me (P.S. after this plist is in binary format) – Mateusz Szlosek Feb 18 '15 at 18:41
  • That worked! If you add it as a answer I will up-vote and accept it so you get reputation for it. – iProgram Feb 18 '15 at 18:45
9

You can use defaults or plutil command line tools.

For defaults it looks like this:

defaults write /absolute/path/to/Info.plist CFBundleExecutable -string <Executable>

For plutil:

plutil -insert CFBundleExecutable -string <Executable> Info.plist 

Value after -insert is a key path separated by .. For example

plutil -insert CFBundleDocumentTypes.0.CFBundleTypeExtensions.1 -string "scss" /Applications/Safari.app/Contents/Info.plist

will insert "scss" string deep in the path. Numbers after . are for arrays (they are starting with 0).

  • 1
    Thanks, but how can you insert into a deeper level of the plist (say add an item to some internal dictionary)? Here you merely present the key, the type and the value - but no key-path. – Motti Shneor Feb 16 '16 at 12:44
  • @MottiShneor I've added example for deeper key path. – Mateusz Szlosek Feb 16 '16 at 13:06
1

For macOS

GET Value

/usr/libexec/PlistBuddy -c "Print : CFBundleExecutable" Info.plist

SET Value

/usr/libexec/PlistBuddy -c "Set : CFBundleExecutable <Executable>" Info.plist

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .