bioffe
bioffe

Reputation: 6383

How to populate Info.plist values dynamically in Xcode?

Can't figure out how to populate CFBundleVersion dynamically with ${BUNDLE_VERSION} which I would like to define as

BUNDLE_VERSION=`date "+%y%m%d"`

Upvotes: 2

Views: 2741

Answers (2)

Ben Stiglitz
Ben Stiglitz

Reputation: 4004

You’ll need an Xcode configuration file and a configuration variable that you set at build time. This is described in some detail at Diego Massanti’s blog. You’ll need to modify the build phase he describes to set the variable to the current date instead of incrementing the existing value.

Upvotes: 1

tc.
tc.

Reputation: 33592

If you're doing command-line builds with xcodebuild, you can do something like

xcodebuild -target MyApp -configuration AppStore BUNDLE_VERSION=`date "+%y%m%d"`

However, I advise against doing this. An App Store app has three versions:

  • The iTunes Connect version number (this is the only one normally shown to the user)
  • CFBundleVersion
  • CFBundleShortVersionString

I think they're all supposed to be of the form [0-9]+.[0-9]+(.[0-9]+)?. To avoid confusion, I set them all to the same thing for App Store builds (we include CFBundleVersion/CFBundleShortVersionString in bug reports, and it's nice if they match CFBundleVersion). Non-App Store builds can include more info, since they don't need to be submitted.

I don't know if iTunes Connect lets you submit an app with CFBundleVersion that doesn't contain a ".", but I haven't extensively tested this.

Upvotes: 2

Related Questions