我正在终端中设置一个变量
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/