简体   繁体   English

我可以在我的iPhone应用程序中使用动态库(共享对象)吗?

[英]can I use dynamic library(shared object) in my iphone app?

As is known to everyone, static libraries can work well in an Iphone App and your App can be easily approved by IOS App Store 众所周知,静态库可以在Iphone应用程序中很好地工作,并且您的应用程序可以很容易地被IOS App Store批准

Unfortunately, the two static libraries I'm using now have the some C functions and variables. 不幸的是,我现在使用的两个静态库有一些C函数和变量。

so I compiled them into *.dylib (dynamic libraries), and copy them to "Bundle Resources" in XCode. 所以我将它们编译成* .dylib(动态库),并将它们复制到XCode中的“Bundle Resources”。

dylib_handle = dlopen(dylib_path_in_resource_bundle, RTLD_LAZY);
func = dlsym(dylib_handle, "func");

// invoke func();

This works well in simulator and Ipad (of course, different dynamic libraries). 这在模拟器和Ipad(当然,不同的动态库)中运行良好。

I noticed that somebody said Iphone app does not support any third party dynamic libraries and my app will be rejected. 我注意到有人说Iphone应用程序不支持任何第三方动态库,我的应用程序将被拒绝。 (see here) (看这里)

but I carefully read the "App Store Review Guidelines", I found no item meet my question. 但我仔细阅读了“App Store评论指南”,我发现没有任何项目符合我的问题。

I'm confused now! 我现在很困惑!

Does iphone app support dynamic libraries? iphone应用程序是否支持动态库? Does IOS AppStore allow this? IOS AppStore是否允许这样做?

Who can give me an official response. 谁能给我官方回复。

As Bernardo Ramos states in a comment: "Since iOS8 we can use dynamic libraries". 正如贝尔纳多·拉莫斯在评论中所述:“自iOS8以来,我们可以使用动态库”。

Dynamic libraries are not allowed by the App Store. App Store不允许使用动态库。 No code may be loaded at run-time. 在运行时不能加载任何代码。 The answer is to convert them to static libraries and compile them into the application. 答案是将它们转换为静态库并将它们编译到应用程序中。

From iPhoneOSTechOverview: 来自iPhoneOSTechOverview:

"If you want to integrate code from a framework or dynamic library into your application, you should link that code statically into your application's executable file when building your project." “如果要将框架或动态库中的代码集成到应用程序中,则应在构建项目时将该代码静态链接到应用程序的可执行文件中。”

Read "should" as "must" 读“应该”为“必须”

See SO Answer: Can create dynamic library for iOS? 请参阅答案: 可以为iOS创建动态库吗?

No, dynamic libraries are not allowed. 不,不允许使用动态库。

But you can create static libraries, and even "static frameworks" (that is, like a classic framework is, a folder with the ".framework" extension and containing your Headers, resource files if any, and the lib itself, except that your lib must be a static library). 但是你可以创建静态库,甚至是“静态框架”(就像经典框架一样,是一个带有“.framework”扩展名的文件夹,包含你的Headers,资源文件,如果有的话)和lib本身,除了你的lib必须是静态库)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM