The process of linking ObjC static libraries to Xcode

I am trying to connect to a static library and I keep getting linker errors. I found several sites that publish examples, but I could not understand what I was doing wrong.

First I create a project that will reference my lib

add> existing files
find the .xcodeproj file
select "Copy items to target groups folder" ...
Select my host project as "Add to targets."

Then I add a direct dependency on my host application
to expand the goals
double click MyHost.app
click + under direct dependencies
select my lib

Then I set the assembly flags

double-click the MyHost application icon in groups and files.

click assembly tab

then I installed OtherLinerFlag for -ObjC
then I set the header search paths to my header file for my static library.

I pass the compilation step, but any classes in my static lib cause a linker error:
  literal-pointer @__ OBJC @__ cls_refs @SomeClass in MyHost.o

thank!

+2
source share
1 answer

The last bit that I was missing, just clicked and dragged the imported library into the "Linking binaries to libraries" section of my target.

expand MyLib.xcodeproj
expand goals
expand MyApp
expand "Link Binary With Libraries"

libMyLib.a MyLib.xcodepoj "Link Binary With Libraries"

, .

http://sites.google.com/site/mikescoderama/Home/using-external-static-libraries-in-objective-c-with-xcode

+3

Source: https://habr.com/ru/post/1794719/


All Articles