如何在iOS上自动导入静态库使用的框架?(How can frameworks used by a static library be automatically imported on iOS?)

系统教程 行业动态 更新时间:2024-06-14 17:04:02
如何在iOS上自动导入静态库使用的框架?(How can frameworks used by a static library be automatically imported on iOS?)

我的公司为iOS应用程序创建了一个静态库。 对于开发人员来说,一个令人烦恼的步骤是他们必须手动链接库所使用的所有必需框架,否则会导致编译器错误有些混乱。

我以前认为这是不可能的,但Chartboost公司声称自动链接到非默认框架,如AdSupport和StoreKit。 基于我在他们的示例应用程序中的测试(可从链接页面获得),到目前为止似乎是这种情况(即使在链接静态库的应用程序中禁用“启用模块”和“自动链接框架”)。

在创建静态库时是否有某种方法可以启用此功能? 我已经尝试在Xcode中启用模块和“Link Frameworks Automatically”LLVM选项,但到目前为止还没有能够使它工作。

My company makes a static library for iOS apps. One annoying step for developers is that they have to manually link against all the required frameworks that the library uses, and failing to do so leads to somewhat confusing compiler errors.

I would have previously thought this wasn't possible, but the company Chartboost claims to automatically link against non-default frameworks like AdSupport and StoreKit. Based on my testing in their sample app (available from the linked page), so far this appears to be the case (Even when disabling "Enable Modules" and "Link Frameworks Automatically" in the app that links against the static library).

Is there some way to enable this feature when creating a static library? I've tried enabling modules and the "Link Frameworks Automatically" LLVM options in Xcode, but so far haven't been able to get it working.

最满意答案

在进行函数或方法调用之前, 有一段代码称为CBDynamicallyLoadedDependencies ,它在相应的系统库上调用 dlopen() 。

我原来的答案不正确。 dlopen()调用只是在x86代码中。 在设备上,它有所不同,但我的ARM组件不够强大,无法弄明白。 我只能说,有一段代码可以作为所需功能的蹦床,并引用系统库文件(如/System/Library/Frameworks/AdSupport.framework/AdSupport)。

但重点是,它不是一个简单的项目技巧,使其正常工作。 涉及内部代码。

There's a piece of code called CBDynamicallyLoadedDependencies that calls dlopen() on the appropriate system library before making the function or method call.

My original answer wasn't correct. the dlopen() call is just in the x86 code. On the device, it's something different, but my ARM assembly isn't strong enough to figure it out. All I can say is that there's a piece of code that's acting as a trampoline to the desired functions and that references the system library files (like /System/Library/Frameworks/AdSupport.framework/AdSupport).

But the point is that it's not a simple project trick that makes it work normally. There's internal code involved.

更多推荐

本文发布于:2023-04-24 20:58:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/dzcp/ce50e7bfa543206a9680f7ea6f6ce672.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:静态   框架   如何在   iOS   frameworks

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!