title: How to create static library for iOS without making all symbols public
body: <p>This question has been asked before, but digging into the documentation for the various development tools it seems like this <em>is</em> possible, just not obvious.</p>
  
  <p>Motivation:
    Making a static library for use by other iOS developers.  Some symbols in the library will cause problems if exported so I wish to make them internal-only symbols.  With a dynamic library this is easy, just use <code>-exported_symbols_list</code> <code>libtool</code> (<code>ld</code>) argument and list the ones you want public.  <code>libtool</code> documentation will not allow this argument for static libraries.</p>
  
  <p>Library has several ObjectiveC .m files that use code from each other.  Only one class in the group needs to be made public to users of the final .a static library file.</p>
  
  <p>Tried <code>libtool -exported_symbols_list publicsymbols.exp</code> but that argument to <code>libtool</code> is not supported with <code>-static</code> for static libraries.</p>
  
  <p>Can't make the symbols private with attributes (if that'd even work) because they are needed by the other .m files in the group.</p>
  
  <p>looks like <code>ld</code> can take several .o files and link them together into a new .o file (via the <code>-r</code> argument) and it doesn't have the "dynamic only" disclaimer for the <code>-exported_symbols_list</code> argument (which could just be unclear documentation...).</p>
  
  <p>just as a test I build my project with Xcode so I have all the .o files made, and then try to call <code>ld</code> on the command line, like so:</p>
  
  <pre><code>ld -r -x -all_load -static -arch armv6 -syslibroot {path} 
     -filelist /Users/Dad/ABCsdk/iphone-ABClib/build/ABCLib.build/Distribution-iphoneos/ABCLib-device.build/Objects-normal/armv6/ABCsdk.LinkFileList 
     -exported_symbols_list {exp file path} -o outputfile.o
  </code></pre>
  
  <p>where the {path} type things have long paths to the appropriate places in there.</p>
  
  <p>but I get errors like the following:</p>
  
  <blockquote>
    <p>/usr/bin/ld_classic: /Users/Dad/ABCsdk/iphone-ABClib/build/ABCLib.build/Distribution-iphoneos/ABCLib-device.build/Objects-normal/armv6/ABCmain.o incompatible, file contains unsupported type of section 3 (_<em>TEXT,</em>_picsymbolstub4) in load command 0 (must specify "-dynamic" to be used)</p>
  </blockquote>
  
  <p>so something seems wrong there...</p>
  
  <p>Anyone know a clever way to make this work?  Thanks.</p>