Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to read environment variables in info.plist?

Tags:

ios

plist

I am setting a variable in the terminal

export VAR=1.0.0

And I have to read it from ~/.bash_profile into the info.plist like for example:

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

So like this I can do automated builds. Is there a way how to read the variables?

like image 864
NinetyHH Avatar asked Apr 20 '17 07:04

NinetyHH


1 Answers

In the info.plist you reference the variable:

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

Then when you build the project from the terminal you inject the value for the VAR:

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

Or if the variable in set in the environment:

xcodebuild build VAR=${VAR} -project myProject.xcodeproj -target myTarget -sdk iphonesimulator
like image 174
Christos Koninis Avatar answered Jan 03 '23 22:01

Christos Koninis