I want to edit project.pbxproj
straight up using command line (for CI server script)
what tools can allow me to do this?
I used to use PlistBuddy
to edit the output Info.plist
; however, what i really want to do is to edit this user defined field, which is used in multiple places, and i really don't want to have to hunt that down in every plist location
project.pbxproj
is an old-style ASCII property list file, too. So you can use /usr/libexec/PlistBuddy
to edit it.
Print some User-Defined key's value like this,
# Get the key A83311AA20DA4A80004B8C0E in your project.pbxproj
# LZD_NOTIFICATION_SERVICE_BUNDLE_ID is defined by me,
# Replace key paths with your own.
/usr/libexec/PlistBuddy -c 'print :objects:A83311AA20DA4A80004B8C0E:buildSettings:LZD_NOTIFICATION_SERVICE_BUNDLE_ID' LAAppAdapter.xcodeproj/project.pbxproj
Set its value like this,
/usr/libexec/PlistBuddy -c 'set :objects:A83311AA20DA4A80004B8C0E:buildSettings:LZD_NOTIFICATION_SERVICE_BUNDLE_ID com.dawnsong.notification-service' LAAppAdapter.xcodeproj/project.pbxproj
UPDATE
PlistBuddy
will automatically convert project.pbxproj
into a xml-format plist file since macOS Catalina (or some earlier version). It's better to move the setting item into xcconfig
file instead since xcconfig
is much smaller and simpler than project.pbxproj
and not easy to make mistakes when editing with perl
script.