Automatic build number incrementing
-
Yep, it's that time of year again where we do our annual "Why the
bleep doesn't PB/Xcode have auto-incrementing build numbers
yet?!? ...and how can we get around it?".
I've just retried all the old solutions from the list archives, using
Perl, shell scripts & Apple scripts, but none of them work with Xcode
2.0, or don't work satisfactorily - i.e. I want to increment
CFBundleVersion (and possibly CFBundleShortVersionString &
CFBundleGetInfoString), not some arbitrary constant in some source file.
So, any ideas? I've tried exploring Xcode 2.0 in Applescript, but I
still can't figure Applescript out (after nearly 10 years of
trying... so much for "Joe Blow's scripting language"), and in any
case the notes in Xcode's dictionary indicate all values regarding
projects are read-only anyway. :(
My next thought is to add a shell script phase to edit the auto-
generated Info.plist... but then I have to store a backup of it
elsewhere (to avoid it being scraped when Xcode rebuilds), which
introduces synchronisation issues et al... not pretty.
Wade Tregaskis (AIM/iChat, Yahoo & Skype: wadetregaskis, ICQ:
40056898, MSN, audio/video iChat & email: <wadetregaskis...>,
Jabber: <wadetregaskis...>)
-- Sed quis custodiet ipsos custodes? -
On May 22, 2005, at 04:50, <wadeslists...> wrote:
> Yep, it's that time of year again where we do our annual "Why the
> bleep doesn't PB/Xcode have auto-incrementing build numbers
> yet?!? ...and how can we get around it?".
I use the following Perl script to inject my Subversion repository
revision into the built products Info.plist CFBundleVersion. It runs
as a last script build phase in my application target. It shouldn't
be that difficult to make it write out an arbitrary build number
instead. Works in Xcode 2.0.
#!/usr/bin/perl -w
use strict;
die "$0: Must be run from Xcode" unless $ENV{"BUILT_PRODUCTS_DIR"};
my $REV = `svn info | grep "^Revision:"`;
my $INFO = "$ENV{BUILT_PRODUCTS_DIR}/$ENV{WRAPPER_NAME}/Contents/
Info.plist";
my $version = $REV;
$version =~ s/^Revision: (\d+)\n/$1/;
die "$0: No Subversion revision found" unless $version;
open(FH, "$INFO") or die "$0: $INFO: $!";
my $info = join("", <FH>);
close(FH);
$info =~ s/([\t ]+<key>CFBundleVersion<\/key>\n[\t ]+<string>).*?(<\/
string>)/$1$version$2/;
open(FH, ">$INFO") or die "$0: $INFO: $!";
print FH $info;
close(FH);
--
Axel Andersson
<axel...>
http://www.zankasoftware.com/ -
Does agvtool not work (I've not tried it since upgrading)?
Dave
On May 21, 2005, at 7:50 PM, <wadeslists...> wrote:
> Yep, it's that time of year again where we do our annual "Why the
> bleep doesn't PB/Xcode have auto-incrementing build numbers
> yet?!? ...and how can we get around it?".
>
> I've just retried all the old solutions from the list archives,
> using Perl, shell scripts & Apple scripts, but none of them work
> with Xcode 2.0, or don't work satisfactorily - i.e. I want to
> increment CFBundleVersion (and possibly CFBundleShortVersionString
> & CFBundleGetInfoString), not some arbitrary constant in some
> source file.
>
> So, any ideas? I've tried exploring Xcode 2.0 in Applescript, but
> I still can't figure Applescript out (after nearly 10 years of
> trying... so much for "Joe Blow's scripting language"), and in any
> case the notes in Xcode's dictionary indicate all values regarding
> projects are read-only anyway. :(
>
> My next thought is to add a shell script phase to edit the auto-
> generated Info.plist... but then I have to store a backup of it
> elsewhere (to avoid it being scraped when Xcode rebuilds), which
> introduces synchronisation issues et al... not pretty.
>
> Wade Tregaskis (AIM/iChat, Yahoo & Skype: wadetregaskis, ICQ:
> 40056898, MSN, audio/video iChat & email: <wadetregaskis...>,
> Jabber: <wadetregaskis...>)
> -- Sed quis custodiet ipsos custodes?
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Cocoa-dev mailing list (<Cocoa-dev...>)
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/dave%
> 40criticalpath.com
>
> This email sent to <dave...>
>
>
-
Hi,
>> I've just retried all the old solutions from the list archives, using
>> Perl, shell scripts & Apple scripts, but none of them work with Xcode
>> 2.0, or don't work satisfactorily - i.e. I want to increment
>> CFBundleVersion (and possibly CFBundleShortVersionString &
>> CFBundleGetInfoString), not some arbitrary constant in some source
>> file.
Not sure if you know this, but you can put a variable into
CFBundleShortVersionString, and then set that variable in the XCode
build settings.
For example, I have CFBundleShortVersionString = $(VERSION_STRING)
and the $(VERSION_STRING) is a variable in the xcode target build
setting that I increment with a perl script in my makefile (i use
xcodebuild). I haven't tried with 2.0 but something very similar should
work. And if agvtool works then you can just use that variable. Agvtool
in 1.5 wouldn't allow a major.minor.revision version and the
marketing-version never worked :(.
Matt


