开发者

Plug-in architecture, access to code in application?

For a project I am doing, I want the Mac application to accept plug-ins. I like the whole idea of just adding Bundles to the application to extend it's functionality.

Only I came across a small question, where I can't find the answer to:

I need to include a JSON parser in my application, for some functionality. Is it possible for a plug-in Bundle to also use that same parser? 开发者_运维百科Or does every plug-in that uses a JSON parser, need to include the parser themselves?

What is the best way to do this for separate Bundles?


On OS X there are two types of loadable things, a dylib and a plugin. (These two terms have specialized technical meaning in the context of mach-o, the binary format OS X uses.)

A loaded dylib can't refer to the libraries in the executable, while a loaded plugin can. As a side effect, a dylib can be loaded to any executable, but a plugin can only be loaded into the executable you specify when you make the plugin.

So you want to make a plugin. There is a template in the XCode to do that. Don't forget to specify the target executable in the linker flag, which can be set somewhere in the inspector.

For more, read Code Loading Programming Topics.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜