Search code examples
cmacosmacos-carbonbundlecore-foundation

How do I get a bundle reference from inside of a plugin with carbon?


I'm writing a C++ plugin in Mac OS X using the Carbon framework (yeah, yeah, I know, Apple is deprecating Carbon, but at the moment I can't migrate this code to Cocoa). My plugin gets loaded by a master application, and I need to get a CFBundleRef reference to my plugin so that I can access it's resources.

The problem is, when I call CFBundleGetMainBundle() during my plugin's initialization routines, that returns a reference to the host's bundle reference, not the plugin's. How can I get a reference to my plugin's bundle instead?

Note: I would rather not use anything determined at compile-time, including calling CFBundleGetBundleWithIdentifier() with a hard-coded string identifier.


Solution

  • See this posting on the carbon-dev mailing list, which seems to be a similar situation.

    The method given there is

    I recommend using CFBundleGetBundleWithIdentifier. Your plug-in should have an unique identifier; something like "com.apple.dts.iTunes_plug-in", etc. Look for the CFBundleIdentifier property in your plug-in's bundle's info.plist.