title: XCode 4:Insert Subversion revision number in Xcode
body: <p>Yes, this is very related to <a href="https://stackoverflow.com/questions/372218/insert-subversion-revision-number-in-xcode">this question</a>, yet I think that question is adequately answered for XCode 3. Not sure if this should be merged or not. </p>
  
  <p>So - Using similar instructions from there, I've long had the nice effect of having build numbers encoded into archived .ipa files, such that Organizer shows versions like "1.0.3281" (where 3281 is the revision via the below build script attached to my iOS target):</p>
  
  <pre><code>REV=`svnversion -nc | /usr/bin/sed -e 's/^[^:]*://;s/[A-Za-z]//'`
  echo "REV=$REV"
  echo "#define kRevisionNumber @\"$REV\"" &gt; ${PROJECT_DIR}/revision.h
  echo "INFOPLIST_PATH=${INFOPLIST_PATH}"
  
  BASEVERNUM=`/usr/libexec/PlistBuddy -c "Print :CFBundleVersion" "${INFOPLIST_FILE}" | sed 's/,/, /g'`
  echo "BASEVERNUM=$BASEVERNUM"
  PLISTARG1="Set :CFBundleVersion $BASEVERNUM.$REV"
  echo "PLISTARG1=$PLISTARG1"
  
  /usr/libexec/PlistBuddy -c "$PLISTARG1" "${TARGET_BUILD_DIR}"/${INFOPLIST_PATH}
  </code></pre>
  
  <p>However, XCode 4 (which I've since come to love) clearly needs some tweaking, as this magic only sort-of works. Here is the result of the scripts above.</p>
  
  <pre><code>REV=3281
  INFOPLIST_PATH=Foo.app/Info.plist
  BASEVERNUM=1.0
  PLISTARG1=Set :CFBundleVersion 1.0.3281
  </code></pre>
  
  <p>And I can see by looking in ~/Library/.../Foo.app/Info.plist that yes, it did update the right version:</p>
  
  <pre><code>&lt;key&gt;CFBundleVersion&lt;/key&gt;
  &lt;string&gt;1.0.3281&lt;/string&gt;
  </code></pre>
  
  <p>So clearly there is an <em>additional</em> file needing updating.. perhaps in the .xcarchive? Any suggestions on where to drill into first? </p>