title: Static Library public headers are not copied to Build/Products folder
body: <p>I have 2 projects, which build one static library each, as well as another project which uses both static libraries.</p>
  
  <p>One of the two static libraries builds fine. The other one does not and the reason for that is that <em>its public headers are not copied to the build folder</em> before the custom shell script runs.</p>
  
  <p>Here is a demonstration of what happens:</p>
  
  <p><strong>SampleA</strong> (the one that works)</p>
  
  <pre><code>Compile MyClass1.cpp ...
  Compile MyClass2.cpp ...
  Libtool /Users/user/Library/Developer/XCode/DerivedData/.....
  Libtool /Users/user/Library/Developer/XCode/DerivedData/.....
  Libtool /Users/user/Library/Developer/XCode/DerivedData/.....
  Create universal binary libSampleA.a ...
  Copy SampleA.h ...in /Users/user/....
  Copy MyClass1.h ...in /Users/user/....
  Copy MyClass2.h ...in /Users/user/....
  Run custom shell script 'Prepare Framework'
  Stripping libSampleA.a 
  --- Build complete
  </code></pre>
  
  <p><strong>SampleB</strong> (the one that does NOT work)</p>
  
  <pre><code>Compile OtherClass1.cpp ...
  Compile OtherClass2.cpp ...
  Libtool /Users/user/Library/Developer/XCode/DerivedData/.....
  Libtool /Users/user/Library/Developer/XCode/DerivedData/.....
  Libtool /Users/user/Library/Developer/XCode/DerivedData/.....
  Create universal binary libSampleB.a ...
  // &gt;&gt;&gt;&gt;&gt; NO HEADER FILES ARE COPIED &lt;&lt;&lt;&lt;&lt;&lt;
  Run custom shell script 'Prepare Framework'
  --- Build fails (header folder does not exist) 
  </code></pre>
  
  <p>My current setup is a workspace that includes all 3 projects, but I used to have 1 project with one nested project for each static library as well. The issue I have remains the same in both setups.</p>
  
  <p><strong>More info</strong></p>
  
  <ul>
  <li>I have tried virtually every instruction, tip and advice I found online for making this work.</li>
  <li>The settings on both projects, as far as I can tell, are identical. Comparing the two project files wasn't very effective. I also haven't compared all the settings of both projects one by one to make sure they are the same (yet).</li>
  <li>The problem is the same in both Debug and Archive builds (I know that archiving behaves differently)</li>
  <li>I have added <code>"$(BUILD_ROOT)/../IntermediateBuildFilesPath/UninstalledProducts/include"</code> and/or <code>"$(PROJECT_TEMP_DIR)/../UninstalledProducts/include"</code></li>
  <li>I have added the headers to the <em>"Build Phases > Copy Headers > Public"</em> section - didn't work</li>
  <li>I have deleted the <em>"Build Phases > Copy Headers"</em> phase completely, as Apple suggest and added the headers to the <em>Copy Files</em> phase - didn't work</li>
  <li>I have added a new group in the static lib project and added all its headers, setting no target to <em>"Add to Targets"</em> - didn't work</li>
  <li>I have quit XCode and tried again, or even restart the mac - didn't work</li>
  </ul>
  
  <p><strong>One difference</strong> between the two libraries is that SampleB (the one that does not build) includes various headers from SampleA. There are no compiler or linker errors, just the error at the end of the build that I describe.</p>
  
  <p><strong>Sources</strong></p>
  
  <p>Some of the sources I have used for the creation of the library, as well as for trying to solve the issue:</p>
  
  <ul>
  <li><a href="https://developer.apple.com/library/ios/technotes/iOSStaticLibraries/Articles/creating.html" rel="nofollow noreferrer">https://developer.apple.com/library/ios/technotes/iOSStaticLibraries/Articles/creating.html</a></li>
  <li><a href="https://stackoverflow.com/questions/5543854/xcode-4-cant-locate-public-header-files-from-static-library-dependancy/9509786#9509786">Xcode 4 can&#39;t locate public header files from static library dependency</a></li>
  <li><a href="https://stackoverflow.com/questions/5584317/compile-build-or-archive-problems-with-xcode-4-and-dependencies">Compile, Build or Archive problems with Xcode 4 (and dependencies)</a></li>
  <li><a href="http://www.blog.montgomerie.net/easy-xcode-static-library-subprojects-and-submodules" rel="nofollow noreferrer">http://www.blog.montgomerie.net/easy-xcode-static-library-subprojects-and-submodules</a></li>
  </ul>
  
  <p>So, do you know what triggers the headers to be copied or not be copied, during the build?</p>
  
  <p>I would suspect that even if one header file is added to the Copy Headers phase or the Copy Files phase, at least this should be copied. But as it turns out, this is not what happens, at least in my case.</p>