如何声明以后将提供的可可类?

发布于 2025-02-01 11:27:56 字数 205 浏览 3 评论 0原文

首先,我不得不说,我远不及Objective-C中的好程序员。

我的问题是我想开发一个插件(在这种情况下最终是迪利布)声明一些可可类。该插件将首先加载,以便其他插件可以使用OBJC运行时声明的类。

不幸的是,由于缺少某些类,我总是在编译其他插件时会遇到错误。我认为提供.h文件或@Class就足够了,但不。

我该如何告诉编译器需要在运行时可以提供某些类?

First I have to say that I am nowhere near a good programmer in Objective-C.

My problem is that I want to develop a plugin (which is ultimately a dylib in this context) declaring some Cocoa classes. This plugin would be loaded first so other plugins would be able to use the classes already declared in the ObjC runtime.

Unfortunately, I always get errors when trying to compile other plugins because some classes are missing. I thought that providing the .h files or @class would be enough but no.

How can I tell the compiler that some classes will be available from the Runtime when it needs it ?

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

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

发布评论

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

评论(2

-残月青衣踏尘吟 2025-02-08 11:27:56

如果您的类在其他二进制中定义,则需要在构建设置中指定bundle_loader键,因此链接器可以找到这些因符号。 (注意:.h文件仅需要编译器才能查找接口声明)。

If your classes defined in other binary, you need to specify BUNDLE_LOADER key in build settings, so linker could find those dependent symbols. (Note: .h files are needed only for compiler to find interface declarations).

demo

扛起拖把扫天下 2025-02-08 11:27:56

该解决方案实际上很容易,因为我只需要在第一个插件内的动态库中脱链链接即可。

即使Dylib实际上嵌入了ZIP档案中,主应用程序仍将其加载到内存中,并将其提供给其他插件。

感谢大家的消息。

The solution was actually easy as I just needed to weak-link against the dynamic library inside the first plugin.

Even though the dylib is actually embedded in a zip archive, the main application loads it in memory and make it available to the other plugins.

Thanks everyone for your messages.

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