我想从任意包标识符创建一个包
例如com.apple.iokit.IOStorageFamily
例如com.apple.iokit.IOStorageFamily
假设捆绑ID,这不是一件不合理的事情
是唯一的,但明显的代码不起作用:
Nsstring* bID = @"com.apple.iokit.IOStorageFamily"; NSBundle* bundle = [NSBundle bundleWithIdentifier:bID];
此代码仅适用于您已加载的捆绑包
(你好,鸡肉和鸡蛋问题),事实上,你有
了解比标识符更多的东西
在你做任何事之前.对于上述风格的ID
我将最后一个组件弄清楚并将其转换为
/System/Library/Extensions/IOStorageFamily.kext
然后我按路径加载.
这是最先进的技术还是有更普遍的方式?
解决方法
就在最近
Andrew Myrick answered a similar question在darwin-dev邮件列表上:
KextManagerCreateURLForBundleIdentifier()
in<IOKit/kext/KextManager.h>
may be
of use,though I believe it only works
for kexts that are either 1) loaded,
or 2) in /S/L/E/. Here is the SNow
Leopard headerdoc:06000
Note that prior to SNow Leopard,it
may only work for kexts in /S/L/E; the
API existed,but there was no
headerdoc describing its behavior.
对我来说,这在Mac OS X 10.5上运行得非常好.