title: How do I create a dynamic library (dylib) with Xcode?
body: <p>I'm building few command-line utilities in Xcode (plain C, no Cocoa). I want all of them to use my customized version of libpng, and I want to save space by sharing one copy of the library among all executables (I don't mind re-distributing <code>.dylib</code> with them).</p>
  
  <p>Do I need to do some magic to get libpng export symbols?</p>
  
  <p>Does <em>"Link Binary With Libraries"</em> build phase link statically? </p>
  
  <p>Apple's docs mention loading of libraries at run time with <code>dlopen</code>, but how I can make Xcode create executable without complaining about missing symbols?</p>
  
  <hr>
  
  <p>I think I've figured it out:</p>
  
  <ul>
  <li><p>libpng wasn't linking properly, because I've built 32/64-bit executables and 32-bit library. Build settings of the library and executables must match.</p></li>
  <li><p>libpng's config.h needs to have tons of defines like <code>#define FEATURE_XXX_SUPPORTED</code></p></li>
  <li><p><em>"Link Binary With Libraries"</em> build phase handles dynamic libraries just fine, and <code>DYLD_FALLBACK_LIBRARY_PATH</code> environmental variable is neccessary for loading <code>.dylib</code>s from application bundle.</p></li>
  </ul>