• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Automatic versioning
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Automatic versioning


  • Subject: Re: Automatic versioning
  • From: Steve Checkoway <email@hidden>
  • Date: Sat, 3 Feb 2007 16:48:50 -0800


On Feb 2, 2007, at 7:54 PM, Jim Thomason wrote:

Here's what I want - a build number that auto-increments every time I
build and does so without my needing to fiddle with it. I'm not
talking about the external user defined version number (1.0.7 or
whatever), I'm talking about a count of how many times I clicked the
"Build button" (368). Possibly of dubious utility, but I've just got a
static build number otherwise.

At times this can be quite useful.

Hence, like so many before me, I appeal to the world. Anybody have a
way to do this easily, automatically, and all from within xcode?

It depends where you want this version number to be incremented. If you want it in some plist, I can't help as I've never done that. If you just want to increment a const int in your program, I can offer a suggestion.


I have a version target upon which my main target depends. This is a custom build tool target. The build tool configuration uses /bin/sh as the build tool and scripts/increment_version.sh as the argument. The bash script is the following:

#!/bin/sh

perl -w -e '
open F, "<version.tst"||die;
$ver = <F>;
close F;
chomp $ver;
++$ver;
open F,">version.tst"||die;
print F "$ver\n";
close F;
$date = `date`;
chomp $date;
open F, ">ver.cpp"||die;
print F "unsigned long version_num = $ver;\n";
print F "const char *version_time = \"$date\";\n";
close F;
'
touch ver.cpp

I no longer remember why I don't just execute this as a perl script. It didn't work at some point in the past and I haven't bothered changing it since this does work. It basically keeps a version number in version.tst (I didn't write this, so don't ask me to explain the extension or why it doesn't just read ver.cpp directly), it reads and increments that value and then writes ver.cpp with the version number and date.

This has to be done in a separate target so that the main target notices that ver.cpp changed and actually recompiles it.

--
Steve Checkoway



Attachment: smime.p7s
Description: S/MIME cryptographic signature

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Automatic versioning
      • From: Steve Checkoway <email@hidden>
References: 
 >Automatic versioning (From: "Jim Thomason" <email@hidden>)

  • Prev by Date: Re: On the use of namespaces to manage versions in C++
  • Next by Date: Re: Automatic versioning
  • Previous by thread: Automatic versioning
  • Next by thread: Re: Automatic versioning
  • Index(es):
    • Date
    • Thread