首页 > 解决方案 > iOS 上的 DLL(dylib) 热重载

问题描述

我正在 iOS 设备上测试 dylib 热重载。(这里有一些关于 dll 热重载的好读物。https://ourmachinery.com/post/dll-hot-reloading-in-theory-and-practice/

它在模拟器上运行良好,因为我可以将 dylib 上传到应用程序的文档目录并 dlopen() 它。

std::string soPath = docPath + "/test.dylib";
auto h = dlopen( soPath.c_str(), RTLD_NOW );

但显然,自 iOS 10 以来,这在设备上是被禁止的。

iOS 10 沙盒中的 dlopen() 被阻止 https://gist.github.com/jonbro/0638a2056e134bc26498

dlopen() 返回 NULL 并且 dlerror() 给我与上述链接相同的错误。

文件系统沙箱阻止了“...”的 mmap()

在 Android 上,它也拒绝在“外部存储”中 dlopen() .so 文件,但在“内部存储”中是允许的。有了应用程序的文件写入权限,我想我可以使用本地文件服务器自动执行该过程。

iOS 上是否有这种类型的存储/目录,我可以在其中上传 dylib 文件和 dlopen() 它?或者任何一种解决方法?

我宁愿不越狱。

谢谢。

标签: c++iosdylibdlopen

解决方案


推荐阅读