SVN revision number in CFBundleVersion

  • Dear Folks,
        does anybody know a clever way to automatically insert the SVN
    revision number in CFBundleVersion into the info.plist file?

    should I write a script to do that? are there special tools to
    archive that?

    thank you!

    Giovanni
  • The problem can be broken into two parts: getting the revision from
    subversion and modifying the plist file.

    Unfortunately, I can't seem to figure out how to get the revision
    number out of the sandbox, Maybe someone else can comment on that.

    As for modifying the plist, I use agvtool for that. In my case, I
    bump the version number (I only increment when building for QA) and
    automatically make a subversion tag for the source.

    SVN_TAG_DIR="tags/MyCoolApp-`agvtool vers -terse`"
    cd .. ; svn cp trunk ${SVN_TAG_DIR} ; svn ci -m "Created copy for $
    {SVN_TAG_DIR}"

    Dave

    On Aug 1, 2005, at 2:08 PM, Giovanni Donelli wrote:

    > Dear Folks,
    > does anybody know a clever way to automatically insert the SVN
    > revision number in CFBundleVersion into the info.plist file?
    >
    > should I write a script to do that? are there special tools to
    > archive that?
    >
    > thank you!
    >
    > Giovanni
    > _______________________________________________
    > 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...>
    >
    >

    ---
    It is dark; you are likely to be eaten by a grue. -Zork
  • you could parse it from the output of svn info.

    On Aug 02, 2005, at 10:43, Dave Camp wrote:

    > The problem can be broken into two parts: getting the revision from
    > subversion and modifying the plist file.
    >
    > Unfortunately, I can't seem to figure out how to get the revision
    > number out of the sandbox, Maybe someone else can comment on that.
    >
    > As for modifying the plist, I use agvtool for that. In my case, I
    > bump the version number (I only increment when building for QA) and
    > automatically make a subversion tag for the source.
    >
    > SVN_TAG_DIR="tags/MyCoolApp-`agvtool vers -terse`"
    > cd .. ; svn cp trunk ${SVN_TAG_DIR} ; svn ci -m "Created copy for $
    > {SVN_TAG_DIR}"
    >
    > Dave
    >
    > On Aug 1, 2005, at 2:08 PM, Giovanni Donelli wrote:
    >
    >
    >> Dear Folks,
    >> does anybody know a clever way to automatically insert the SVN
    >> revision number in CFBundleVersion into the info.plist file?
    >>
    >> should I write a script to do that? are there special tools to
    >> archive that?
    >>
    >> thank you!
    >>
    >> Giovanni
    >> _______________________________________________
    >> 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...>
    >>
    >>
    >>
    >
    > ---
    > It is dark; you are likely to be eaten by a grue. -Zork
    >
    > _______________________________________________
    > 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/<mesagen...>
    >
    > This email sent to <mesagen...>
    >
  • Parts of following script will replace any ${VARIABLE} token in a
    product's Info.plist file with the corresponding VARIABLE environment
    variable. So, in your Info.plist file, you would set CFBundleVersion
    to ${REVISION}, and the script below will replace it with the current
    revision.

    Please note that it is quite possible to have an old revision number
    if you do not update your repository. For example, if you make a
    commit from revision 25 to 26, and do not perform an update on the
    repository before running this script, you will get 25 in your
    Info.plist as the CFBundleVersion. This is simply how Subversion works.

    And now, the script. Please note the rather ugly way to find
    Subversion. This certainly could be improved, but you'll get the idea.

    # START OF SCRIPT

    SUBVERSION=`defaults read com.apple.Xcode XCSubversionToolPath 2>/dev/
    null`
    if [ "${?}" != 0 ] ; then
        SUBVERSION="/usr/local/subversion/bin/svn"
    fi

    export REVISION=`$SUBVERSION info | sed -n '/Revision/s/Revision: //p'`

    rm "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}"
    cp "${INFOPLIST_FILE}" "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}"

    perl -i -pe 's/\$\{([^}]*)\}/$ENV{$1}/g' "${TARGET_BUILD_DIR}/$
    {INFOPLIST_PATH}"

    # END OF SCRIPT

    On Aug 1, 2005, at 17:08, Giovanni Donelli wrote:

    > Dear Folks,
    > does anybody know a clever way to automatically insert the SVN
    > revision number in CFBundleVersion into the info.plist file?
    >
    > should I write a script to do that? are there special tools to
    > archive that?
    >
    > thank you!
    >
    > Giovanni
    > _______________________________________________
    > 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/bahamut%
    > 40macstorm.org
    >
    > This email sent to <bahamut...>
    >

    Jean-Francois Roy

    --
    Co-Founder of MacStorm
    Programmer at MacStorm

    http://www.macstorm.org
    <bahamut...>

    http://www.macstorm.org/bahamut/Jean-Francois.gpgkey
  • On Aug 3, 2005, at 2:01 AM, Jean-Francois Roy wrote:

    > Please note that it is quite possible to have an old revision
    > number if you do not update your repository. For example, if you
    > make a commit from revision 25 to 26, and do not perform an update
    > on the repository before running this script, you will get 25 in
    > your Info.plist as the CFBundleVersion. This is simply how
    > Subversion works.
    >
    >

    I've been working on solving the same problem this week, and I came
    up with the following script. I have a Run Script phase as my first
    build phase and this is from the beginning of the script. It hasn't
    seen much use, but seems to work. In short, it performs an "svn
    update ." on the working copy directory if the repository is reachable.

    svnPath="/usr/local/subversion/bin/svn"

    repoURL=`${svnPath} info | awk '$1=="URL:" { print $2 }'`
    ${svnPath} info $repoURL > /dev/null && canReachRepo=YES
    if [ "${canReachRepo}" == "YES" ] ; then
        ${svnPath} update .
    fi

    Also, here is an idea incrementing build numbers from a discussion in
    May <http://lists.apple.com/archives/cocoa-dev/2005/May/msg02561.html>:

    > 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 :(.
    >

    Hope this helps,
  • On 8/1/05, Giovanni Donelli <gdonelli...> wrote:
    > Dear Folks,
    > does anybody know a clever way to automatically insert the SVN
    > revision number in CFBundleVersion into the info.plist file?

    How about using Subversion keywords?

    Put '$Revision$' at the appropriate place in your file, then:
      $ svn propset svn:keywords Revision info.plist
    to enable keyword expansion in the file.

    Subversion will then expand occurrences of $Revision$ as appropriate
    on next checkout.

    Unfortunately Subversion's expansion includes the dollars and the
    keyword; you'll have to use a script to strip it out if that's what
    you want, for example:
      $ perl -pi -e 's/\$Revision: (.*)\$/$1/' info.plist

    pab.
previous month august 2005 next month
MTWTFSS
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31        
Go to today