在XCode中链接静态ObjC库的过程 [英] Process for linking static ObjC libraries in XCode

查看:71
本文介绍了在XCode中链接静态ObjC库的过程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试链接到静态库,并且不断收到链接器错误.我发现了一些张贴示例的网站,但无法看到我做错了什么.

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.

首先,我创建一个项目,该项目将链接到我的lib

First I create a project that will link to my lib

添加>现有文件
找到我的.xcodeproj文件
选择将项目复制到目标组文件夹" ...
选择我的宿主项目作为添加到目标".

add> existing files
find my .xcodeproj file
select "Copy items into destination groups folder"...
Select my host project as Add To Targets.

然后,我将直接依赖项添加到主机应用程序中
扩大目标
双击MyHost.app
在直接依赖项下单击+
选择我的库

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

然后我设置了构建标志

在组和文件"中双击MyHost应用程序图标.

double click MyHost application icon in Groups and Files.

点击构建"标签

然后将OtherLinerFlag设置为-ObjC
然后将标头搜索路径设置为我的静态库的标头文件位置.

then I set the OtherLinerFlag to -ObjC
then I set Header Search Paths to my header file location for my static library.

我通过了编译阶段,但是我的静态库中的任何类都导致链接器错误:
MyHost.o中的literal-pointer @__ OBJC @__ cls_refs @ SomeClass

I pass the compile stage but any classes in my static lib cause linker error:
literal-pointer@__OBJC@__cls_refs@SomeClass in MyHost.o

谢谢!

推荐答案

我所缺少的最后一点就是简单地单击导入的lib并将其拖动到目标的使用库链接二进制文件"部分.

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.

展开MyLib.xcodeproj
扩大目标
展开MyApp
展开使用库链接二进制文件"

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

单击MyLib.xcodepoj下的libMyLib.a并将其拖动到将二进制文件与库链接"

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

这篇关于在XCode中链接静态ObjC库的过程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆