Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I read a custom key's value in Info.plist and use it in Xcode's build settings?

I am attempting to read a custom info.plist key's value into a User Defined Build Setting.

The 'APP_VERSION' is a macro defined in my INFOPLIST_PREPROCESSOR_DEFINITIONS file.

What I am trying to accomplish is getting macro definitions from my INFOPLIST_PREPROCESSOR_DEFINITIONS file into build settings based on different configurations.

I am going about this the wrong way? Or am I just missing something.

info.plist custom key

build settings

like image 443
Mark Norgren Avatar asked Nov 01 '22 09:11

Mark Norgren


1 Answers

You can use the PlistBuddy command in a 'Run Script Build Phase' to read and/or write values in your info.plist file.

To read:

/usr/libexec/PlistBuddy -c 'print PRX_APP_VERSION' Info.plist

To write:

/usr/libexec/PlistBuddy -c "Set :BUNDLE_DISPLAY_NAME NEW_VALUE" Info.plist

So in your Run Script Build Phase, read the value (or values) you want, store them into variables using standard shell scripting, modify as required, then write the values back to the new keys etc.

like image 93
Dave Wood Avatar answered Nov 12 '22 12:11

Dave Wood