title: Why is "xcodebuild: command not found" in this build script?
body: <p>Hi I have the following in the root of my xcode project:</p>
  
  <pre><code>#!/bin/bash
  xcodebuild -scheme target1 clean;
  xcodebuild -scheme target1 archive;
  xcodebuild -scheme target2 clean;
  xcodebuild -scheme target2 archive;
  </code></pre>
  
  <p>However, this only executes the first line <code>xcodebuild -scheme target1 clean;</code> and then yields </p>
  
  <pre><code>...
  ** CLEAN SUCCEEDED **
  
  xcodebuild: command not found
  xcodebuild: command not found
  xcodebuild: command not found
  </code></pre>
  
  <p>Disclaimer: I'm an absolute Mac OS X / Unix greenhorn.</p>
  
  <p><strong>Edit</strong>: Following kranteg's suggestion I added pwd to the script:</p>
  
  <pre><code>#!/bin/bash
  pwd;
  xcodebuild -scheme target1 clean;
  pwd;
  xcodebuild -scheme target1 archive;
  pwd;
  xcodebuild -scheme target2 clean;
  pwd;
  xcodebuild -scheme target2 archive;
  pwd;
  </code></pre>
  
  <p>The output:</p>
  
  <pre><code>/Users/CKU/Programme/uraClient
  === CLEAN TARGET uraClient OF PROJECT uraClient WITH CONFIGURATION Debug ===
  
  Check dependencies
  
  &lt;... lots of compiler messages about the clean ...&gt;
  
  ** CLEAN SUCCEEDED **
  
  /Users/CKU/Programme/uraClient
  xcodebuild: command not found
  /Users/CKU/Programme/uraClient
  xcodebuild: command not found
  /Users/CKU/Programme/uraClient
  xcodebuild: command not found
  /Users/CKU/Programme/uraClient
  </code></pre>
  
  <p><strong>Edit 2</strong>: Replacing the pwd with echo $PATH yields a better result, now the script performs the first three xcodebuild commands before failing. However, the PATH variable seems to be unaffected by xcodebuild:</p>
  
  <pre><code>/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:Desktop/adt-bundle-mac-x86_64-20130522/sdk/platform-tools
  === CLEAN TARGET uraClient OF PROJECT uraClient WITH CONFIGURATION Debug ===
  
  &lt;... log messages ...&gt;
  
  ** CLEAN SUCCEEDED **
  
  /usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:Desktop/adt-bundle-mac-x86_64-20130522/sdk/platform-tools
  === BUILD TARGET uraClient OF PROJECT uraClient WITH CONFIGURATION Release ===
  
  &lt;... log messages ...&gt;
  
  ** ARCHIVE SUCCEEDED **
  
  
  The following commands produced analyzer issues:
      AnalyzeShallow uraClient/SQLiteLibrary/SQLiteManager.m
      AnalyzeShallow uraClient/URA/NSString+UrlEncoding.m
      AnalyzeShallow uraClient/Services/UraTripPredictionsProvider.m
      AnalyzeShallow uraClient/UtilityAppViewController/ViewController.m
      AnalyzeShallow uraClient/RNCryptor/RNDecryptor.m
      AnalyzeShallow uraClient/RNCryptor/RNEncryptor.m
      AnalyzeShallow uraClient/RNCryptor/RNOpenSSLCryptor.m
      AnalyzeShallow uraClient/RNCryptor/RNOpenSSLDecryptor.m
      AnalyzeShallow uraClient/RNCryptor/RNOpenSSLEncryptor.m
  (9 commands with analyzer issues)
  /usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:Desktop/adt-bundle-mac-x86_64-20130522/sdk/platform-tools
  === CLEAN TARGET uraAseag OF PROJECT uraClient WITH CONFIGURATION Debug ===
  
  &lt;... log messages ..&gt;
  
  ** CLEAN SUCCEEDED **
  
  /usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:Desktop/adt-bundle-mac-x86_64-20130522/sdk/platform-tools
  xcodebuild: command not found
  /usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:Desktop/adt-bundle-mac-x86_64-20130522/sdk/platform-tools
  </code></pre>