如何构建适用于 os3.x 和 os4.x 的通用静态库

发布于 2024-09-28 03:14:33 字数 949 浏览 0 评论 0原文

您好,我正在尝试创建一个可以添加到任何 ios 项目的静态库,但我只能让它工作,如果我在 ios3 中构建该库,它将适用于 ios3 项目,但不适用于 ios4,反之亦然。

我得到的错误是:

未定义的符号: “.objc_class_name_UIImage”,引用自: Test3-Release.a(TestViewController.o) 中的文字指针@_OBJC@_cls_refs@UIImage “.objc_class_name_NSNotificationCenter”,引用自: Literal-pointer@_OBJC@_cls_refs@NSNotificationCenter in Test3-Release.a(Test.o)

所以看起来它没有找到该库的 Foundation 和 UIKit 框架?

这是我到目前为止所做的:

我有 2 个项目:1 是一个具有库构建目标的库项目。另一个是一个测试项目,尝试使用第一个库中构建的库。

1) 创建一个包含静态库目标的项目,并添加所有实现文件

2) 将 UIKit、Foundation 等库添加到“Link Binary with Libraries”文件夹中,并将所有链接库设置为在我的库目标中具有弱类型3

)构建库,将其与头文件一起添加到我的测试项目

中4)在我的测试项目中,我将所有构建配置的其他链接器标志设置为-ObjC -all_load

当我编译时,它给了我一堆。错误就好像我没有包含任何框架一样。

有人对我应该做什么有任何想法吗

? 我还注意到,将任何框架添加到我的库目标中的“Link Binary with Libraries”文件夹中似乎没有执行任何操作。我将 CoreLocation 添加到该文件夹​​,但是当我尝试在测试项目中进行编译时,直到将 CoreLocation 添加到我的测试项目框架文件夹时,它才会编译。

Hi I'm trying to create a static library that can added to any ios project, but I can only get it to work such that if I build the library in ios3, it'll work for ios3 projects but not ios4 and vice versa.

The errors I get are:

Undefined symbols:
".objc_class_name_UIImage", referenced from:
literal-pointer@_OBJC@_cls_refs@UIImage in Test3-Release.a(TestViewController.o)
".objc_class_name_NSNotificationCenter", referenced from:
literal-pointer@_OBJC@_cls_refs@NSNotificationCenter in Test3-Release.a(Test.o)

So it looks like it's not finding Foundation and UIKit frameworks for the library?

Here's what I've done so far:

I have 2 projects: 1 is a library project with a library build target. The other is a Test Project that tries to use the library built in the first library.

1) Create a project with a static library target and added all of the implementation files

2) Added libraries like UIKit, Foundation, etc to the "Link Binary with Libraries folder and Set all the linked libraries to have a weak type in my library target.

3) Built the library, added it to my test project, along with my header files.

4) In my test project, I set other linker flags to -ObjC -all_load for all build configurations

When I compile it gives me a bunch of errors as if I didn't include any frameworks.

Anyone have any ideas on what I should do?

Hint (Maybe?)
I also noticed that adding any frameworks to the "Link Binary with Libraries" folder in my library target doesn't seem to do anything. I added CoreLocation to that folder, but when I try to compile in my Test Project it won't compile until I add CoreLocation to my Test Project Frameworks folder.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

情场扛把子 2024-10-05 03:14:33

您的依赖项目(使用静态库)尚未链接 Framewrok 库。

只需添加到依赖的项目框架(uikIt、Foundation 等)即可正常工作。

your dependent project (that uses static library) hassn't linked Framewrok libraries.

Just add to dependent project frameworks (uikIt,Foundation, etc) all will work fine.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文