框架与捆绑包
我希望能够为我正在开发的应用程序添加插件,因为它是一个开发工具,我希望其他人能够编写自己的插件。
所以我的问题是框架和可加载包之间的真正区别是什么?哪些更适合作为插件(访问标头等)?如果我使用可加载包,如何在运行时加载它们并在开发过程中访问它们的功能?
插件不应依赖其他插件。
I want to be able to add plugins for an application I am developing and as it is a development tool I want other people to be able to write their own plugins.
So my questions are what are the real differences between a framework and a loadable bundle? Which are more suited to being a plugin(accessing of headers, ect) ? And if I use loadable bundles how do I load them at runtime and access their functionality during development?
The plugins should not have to rely on other plugins.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您是否看过 NSBundle?它具有在运行时加载可执行代码所需的所有方法。您需要定义某种插件接口,任何插件都将符合该接口。
至于捆绑包和框架之间的区别...捆绑包和框架都是文件结构,其中包含您的应用程序可以使用的各种资源。框架就像一个库——它是您的程序在构建时所链接的东西。另一方面,捆绑包本质上是一个文件夹结构,其中包含在运行时加载的已编译代码。
Have you taken a look at NSBundle? It has all the methods you'll need to load the executable code at runtime. You'll want to define some sort of plugin interface to which any plugin will conform.
As for the difference between bundles and frameworks... Both bundles and frameworks are file structures that contain various resources that your app can use. A framework is like a library -- it's something your program links against when you build it. A bundle, on the other hand, is essentially a folder structure containing compiled code that you load at runtime.
详细说明已接受的答案,捆绑包更多地设计为在程序执行期间加载,然后可能在稍后的时间卸载。框架一旦加载,就被设计为在进程的整个生命周期中一直存在。
框架还被设计为自包含的代码单元,调用者可以在其中调用框架导出的 API。当您想要对调用者的公共 API 进行代码调用时,可以使用捆绑包。查看 ld64 的手册页。您可以通过
-bundle_loader
等选项获取有关捆绑包预期用途的提示Elaborating on the accepted answer, a bundle is more designed to be loaded and then potentially unloaded at a later time during program execution. Frameworks, once loaded are designed to stick around for the life of the process.
Frameworks are also designed to be self contained units of code where a caller calls into the APIs the frameworks exports. Bundles can be used when you want to have code call into the caller's public APIs. Check out ld64's man page. You can get hints for the intended usage of bundles with such options like
-bundle_loader