ios - 如何读取 info.plist 中的环境变量?

标签 ios plist

我正在终端中设置一个变量

export VAR=1.0.0

我必须将它从 ~/.bash_profile 读取到 info.plist 中,例如:

<key>CFBundleShortVersionString</key>
<string>VAR</string>

这样我就可以进行自动化构建。有没有办法读取变量?

最佳答案

info.plist 中引用变量:

<key>CFBundleShortVersionString</key>
<string>$(VAR)</string>

然后,当您从终端构建项目时,您将注入(inject) VAR 的值:

xcodebuild build VAR=123 -project myProject.xcodeproj -target myTarget -sdk iphonesimulator

或者如果在环境中设置变量:

xcodebuild build VAR=${VAR} -project myProject.xcodeproj -target myTarget -sdk iphonesimulator

关于ios - 如何读取 info.plist 中的环境变量?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43513152/

相关文章:

ios - 如何使用 Objective-C 为特定 View Controller 创建单独的方向?

ios - 如何使用 NSMutableArray 的内容填充 Core Data/SQLite DB

Swift UIButton 从 Plist 键设置标题

ios - 编辑 plist 中的现有数据

ios - 发送到已释放实例的消息 - 视为属性

ios - 使用 alamofire 的多部分/表单数据

objective-c - 无法更改/替换 NSDictionary 键值 IOS

ios - 通过 UIButton 将数据传递到另一个 Controller 上的 UITableView

iphone - Tableview 的 Plist 搜索

ios - 如何将数组中的字符串值绑定(bind)到 uibutton(静态)