Sam YC
Sam YC

Reputation: 11617

xcode build svn number insertion does not work

I have tried these 2 Run Script in my xcode's Build Phases, but they both don't work:

1)

REV=`svnversion -nc | /usr/bin/sed -e 's/^[^:]*://;s/[A-Za-z]//'`
buildplist="$PROJECT_DIR/build.plist"
/usr/libexec/PlistBuddy -c "Set :STBuildNumber $REV" ${buildplist}

2)

plist="$PROJECT_DIR/build.plist"
svn update
rev=$(svn info | grep '^Revision:' | sed -e 's/^Revision: //')
/usr/libexec/PlistBuddy -c "Set :STBuildNumber $rev" "$plist"

I have a build.plist file in the project folder and the key value is "STBuildNumber". Every time I build the project, the value is always set to 0.

Anyone know what could be the possible reason? I use Cornerstone as the SVN client but not the xcode's original client. I am using virtual box to run the Mac OS as well. I always check out the lastest project file from the SVN but only me cannot get the SVN number but my friend is able to get it. He also checked out the same project file from SVN.

Thank for any help.

Upvotes: 1

Views: 253

Answers (1)

ıɾuǝʞ
ıɾuǝʞ

Reputation: 2849

What we do is to generate a header file (ignored by svn), be sure to make your scripts run before "Compile Sources" phase by dragging them up in the list.

For information, here is our script :

VERS=`/usr/libexec/PlistBuddy ${INFOPLIST_FILE} -c "print CFBundleVersion"`
REV=`svnversion -n`
if [ "$?" -eq "0" ] && [ "$CONFIGURATION" != "Distribution" ] ; then
  REV=$VERS"-r"$REV;
else
  REV=$VERS;
fi
echo "#define VersionString @\"$REV\"" > ${PROJECT_DIR}/version.h

Only debug version have the revision in the version string : 1.0-r212 for example. When we export the source outside svn, svnversion reports "exported".

Upvotes: 1

Related Questions