简体   繁体   English

如何在Info.plist中读取自定义键的值并在Xcode的构建设置中使用它?

[英]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. 或者我只是遗漏了一些东西。

info.plist自定义键

构建设置

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.

相关问题 我可以在另一个Info.plist键值的内部使用Info.plist中一个键的值吗? - Can I use the value for one key in Info.plist inside the value of another Info.plist key? Copy Bundle Resources 构建阶段包含此目标的 Info.plist 文件 'Info.plist' in xcode 6? - The Copy Bundle Resources build phase contains this target's Info.plist file 'Info.plist' in xcode 6? 如何在构建设置中从Info.plist读取值? - How can you read values from Info.plist in build settings? 如何在 info.plist 文件中使用 Code 值 xcode ios - How to use Code value in the info.plist file xcode ios 我可以在我的主机应用中阅读我的应用扩展程序的info.plist吗? - Can I read my app extension's info.plist in my host app? 如何配置我的目标以在Xcode中使用特定的Info.plist? - How can I configure my target to use a specific Info.plist in Xcode? Flutter/iOS:如何在 NotificationServiceExtension Info.plist 文件中使用 pubspec.yaml 的 App 版本? - Flutter/iOS: How can I use pubspec.yaml's App version in my NotificationServiceExtension Info.plist file? 如何使用简单的字符串更改自定义 Info.plist 键 - how can I change custom Info.plist key with simple string 使用 Xcode 的“新构建系统”写入构建目录 info.plist - Writing to build directory info.plist using Xcode's "New Build System" Xcode:如何将密钥添加到生成的 Info.plist 文件中(或合并生成的和现有的 Info.plist)? - Xcode: How to add key into generated Info.plist file (or merge generated and existing Info.plist)?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM