Process for linking static ObjC libraries in XCode
I'm trying to link to a static library and I keep getting linker errors. I've found a few sites that post examples but I have not been able to see what I am doing wrong.
First I create a project that will link to my li开发者_运维百科b
add> existing files
find my .xcodeproj file select "Copy items into destination groups folder"... Select my host project as Add To Targets.Then I add a direct dependency to my host app
expand targets double click MyHost.app click + under direct dependencies select my libThen I set build flags
double click MyHost application icon in Groups and Files.
click the build tab
then I set the OtherLinerFlag to -ObjC
then I set Header Search Paths to my header file location for my static library.I pass the compile stage but any classes in my static lib cause linker error:
literal-pointer@__OBJC@__cls_refs@SomeClass in MyHost.othanks!
The final bit I was missing was simply to click and drag the imported lib to the "Link Binary With Libraries" section of my target.
expand MyLib.xcodeproj
expand targets
expand MyApp
expand "Link Binary With Libraries"
Click and drag libMyLib.a under MyLib.xcodepoj to "Link Binary With Libraries"
I made a doc that covers all of the steps here.
http://sites.google.com/site/mikescoderama/Home/using-external-static-libraries-in-objective-c-with-xcode
精彩评论