title: Bash script to edit CFBundleVersion field of PROJECT-Info.plist file
body: <p>In order to put in place a continuous integration system, Hudson, I wrote a bash script to build Xcode project automatically.
  Moreover, in Debug configuration, It was asked to me, to insert the svn revision number of the project in the CFBundleRevision field of the PROJECT-Info.plist file as ${BUNDLE_VERSION}.r${SVN_REVISION}.</p>
  
  <p>You'll find the source code of PROJECT-Info.plist file below : </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"&gt;
  &lt;plist version="1.0"&gt;
  &lt;dict&gt;
  [...]
      &lt;key&gt;CFBundleVersion&lt;/key&gt;
      &lt;string&gt;1.0&lt;/string&gt;
  [...]
  &lt;/dict&gt;
  &lt;/plist&gt;
  </code></pre>
  
  <p>I tried this bash script below : </p>
  
  <pre><code>sed 'N;s_^.*&lt;key&gt;CFBundleVersion&lt;/key&gt;.*&lt;string&gt;[0-9][0-9]*\.[0-9][0-9]*&lt;/string&gt;$_&lt;key&gt;CFBundleVersion&lt;/key&gt;\
  &lt;string&gt;'"$BUNDLE_VERSION"'\.r'"$SVN_REVISION"'&lt;/string&gt;_' $PROJECT-Info.plist
  </code></pre>
  
  <p>This script should replace the "1.0" string with ${BUNDLE_VERSION}.r${SVN_REVISION} (just in standard output currently).
  However, the replacement works without the 'N' option which includes the next line in the sed process and for one line at a time. But there is many line with "<code>&lt;string&gt;[...]&lt;/string&gt;</code>" string in the PROJECT-Info.plist file...</p>
  
  <p>I think it's my way of processing the unknown characters between the two lines ('N' option and ".*" for any characters) is wrong.</p>
  
  <p>Any idea ?</p>
  
  <p>Thanks in advance and sorry for my bad level in English.</p>