[英]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. 我试图将自定义info.plist键的值读入用户定义的构建设置。
The 'APP_VERSION' is a macro defined in my INFOPLIST_PREPROCESSOR_DEFINITIONS file. 'APP_VERSION'是我的INFOPLIST_PREPROCESSOR_DEFINITIONS文件中定义的宏。
What I am trying to accomplish is getting macro definitions from my INFOPLIST_PREPROCESSOR_DEFINITIONS file into build settings based on different configurations. 我想要实现的是从我的INFOPLIST_PREPROCESSOR_DEFINITIONS文件中获取宏定义到基于不同配置的构建设置。
I am going about this the wrong way? 我这是错误的方式吗? Or am I just missing something.
或者我只是遗漏了一些东西。
You can use the PlistBuddy
command in a 'Run Script Build Phase' to read and/or write values in your info.plist file. 您可以在“运行脚本构建阶段”中使用
PlistBuddy
命令来读取和/或写入info.plist文件中的值。
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. 因此,在运行脚本构建阶段,读取所需的值(或多个值),使用标准shell脚本将它们存储到变量中,根据需要进行修改,然后将值写回新的键等。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.