views:

42

answers:

2

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"`

Anyone?

+1  A: 

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.

Ben Stiglitz
I studied the lifecycle of xcode build. it evals Info.plist first and onlythen it execs build phases. It's not really dynamic as it creates a state to be used in the next iteration of the build. I have an improvement for Diego. He should really edit(postprocess) Info.plist in the built folder and gain the dynamic aspect. Thanks to you, I see how it can be achieved, but it's awfully ugly
bioffe
A: 

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.

tc.
CFBundleShortVersionString is what being used by AppStore.app and ITunes Store. CFBundleVersion is seen only from iTunesConnect's MetaData. I had CFBundleVersion as unsigned integers since 2008 with no problems. I am trying to make this field slightly usefull to identify time of the build, rather than application's version.
bioffe
No; the store shows whatever enter as the "Version" in iTunes Connect. If you're going to use it as a timestamp, I'd be tempted to include the time too (yyyyMMdd.HHmmss); this means it's easier to differentiate between multiple builds from the same day. That said, a better way to tag the build is to include you own Info.plist key ("DetailVersion" perhaps) which can be in any format you like. I include the branch, SVN revision, configuration, and build number.
tc.
if you use Enterprise deployment model(or Ad-hoc), there is no Itunes Connect involved. In desktop iTunes software it shows CFBundleShortVersionString as version.
bioffe
I specifically said App Store. Ad Hoc apps aren't shown on the App Store.
tc.