title: Xcode 4 Archive build not finding imports in precompiled headers
body: <p>I have a project which won't Archive-build correctly in Xcode 4.  It appears to me that the "Build For Archiving" and "Archive" commands build differently, and I cannot determine any reason why!</p>
  
  <p>Details:</p>
  
  <ul>
  <li>The workspace contains two projects: an app and a static library; the projects are arranged as peers.</li>
  <li>"Build" and "Run" both work correctly; app executes in iOS simulator and on device.</li>
  <li>"Build for Running", "Build for Testing", "Build for Profiling", and "Build for Archiving" all work correctly also.
  <ul>
  <li>Build for Running is debug, Build for Profiling is release, so both configuration have been tested.</li>
  </ul></li>
  <li>"Archive" fails!</li>
  </ul>
  
  <p>Failure 1 (Library):<br><br>
  When I try to execute the "Archive" command on the library, a custom resource script fails.  The script is reading from the resources directory ($RESOURCES_DIR)<br/></p>
  
  <p>For release builds, this maps to:</p>
  
  <blockquote>
    <p>...DerivedData/App-uniquecrap/Build/Products/Release-iphoneos/Resources/LibraryName</p>
  </blockquote>
  
  <p>For the archive, this maps to:</p>
  
  <blockquote>
    <p>...DerivedData/App-uniquecrap/ArchiveIntermediates/Build Frameworks/BuildProductsPath/Release-iphoneos/Resources/LibraryName</p>
  </blockquote>
  
  <p>Except <code>Resources</code> is missing in the <code>ArchiveIntermediates</code> tree!</p>
  
  <p>UPDATE: The first part of the problem is caused by poor quoting in the script file.  Xcode4's paths now include a folder with an embedded space (imagine that!) and improperly quotes paths don't work as well as we would like.  That fixed, I still have the problem that the resource files copied by the Gather Resources build phase are not going to the correct location; the script expects them in $(RESOURCE_DIR), but I can't seem to find the correct setting in Gather Resources to send them there.  Suggestions?</p>
  
  <p>Failure 2 (App):<br><br>
  When I have managed to kludge my way part the first failure (typically by copying files and bypassing the script), I run into another error building the App.  "Archive" complains that it can't find imported files when building the precompiled headers.</p>
  
  <p>Nothing unusual here either; headers are imported in pch file in the typical manner: </p>
  
  <pre><code>#import &lt;LibraryName/Library.h&gt;
  </code></pre>
  
  <p>As before, "Build", "Build for Archiving", etcetera succeed without problem.  "Archive" fails.  Either the include paths are set up correctly and "Archive" is ignoring them; or the include paths are set up incorrectly and Xcode is auto-magically fixing them in the other builds.  (Either way, I'm very frustrated).</p>
  
  <p>How can I (A) make Archive builds work; or (B) figure out what is going on, so I can accomplish (A)?</p>
  
  <p>Thanks.</p>