Skip navigation.
 
mlRe: Trouble loading bundles at runtime
FROM : Jonathan Hess
DATE : Wed Feb 06 23:12:43 2008

On Feb 6, 2008, at 9:36 AM, Alexander Griekspoor wrote:

> Hi all,
>
> On tiger I used to be able to load bundles at runtime using the code 
> below, this doesn't seem to work on Leopard anymore however:
>
> - (BOOL)addMyPluginBundle: (NSString *)path{
>    Class pluginClass;
>    NSBundle *pluginBundle;
>
>    id aPlugin = nil;
>    BOOL nibLoaded = NO;
>
>    pluginBundle = [NSBundle bundleWithPath: path];
>    if (pluginClass = [pluginBundle principalClass]) {
>        if ([pluginClass 
> conformsToProtocol:@protocol(myPluginProtocol)] ) {
>         aPlugin = [[pluginClass alloc] init];
>         nibLoaded = [NSBundle loadNibNamed:  [[pluginBundle 
> infoDictionary] objectForKey: @"NSMainNibFile"] owner: aPlugin];
>        }
>    }
>     
>    if ( aPlugin && nibLoaded) {
>     //do some stuff    
>  }
>
>    return YES;
> }


Hey Alexander -

I'm not sure that this is your problem, but I would expect to see a 
call to [pluginBundle load] right after pluginBundle is set to 
[NSBundle bundleWithPath: path]. Having an instance of NSBundle 
doesn't imply that the code for the bundle has been loaded into your 
address space.

Jon Hess

>
>
> The weird thing is that this only happens if I just before have 
> download the bundle and wrote it to disk. If I restart my main app 
> and use the exact same code to load the bundle it works fine. What 
> happens is that instead of the bundle's nib file the main app's nib 
> is loaded again!?! Diving a bit further into it shows that this is 
> because the [pluginBundle infoDictionary] doesn't contain the 
> complete plist of the bundle (although it definitely is there!) and 
> lacks the NSMainNibFile entry.
>
> If I run this code at startup the plist looks like:
>
> dict: {
>    CFBundleDevelopmentRegion = English;
>    CFBundleExecutable = WOSSearchEngine;
>    CFBundleExecutablePath = "/Users/griek/Library/Application 
> Support/Papers/PlugIns/SearchEngines/WOSSearchEngine.searchengine/
> Contents/MacOS/WOSSearchEngine";
>    CFBundleIconFile = searchengine;
>    CFBundleIdentifier = "com.mekentosj.papers.WOSSearchEngine";
>    CFBundleInfoDictionaryVersion = "6.0";
>    CFBundleInfoPlistURL = Contents/Info.plist -- file://localhost/Users/griek/Library/Application%20Support/Papers/PlugIns/SearchEngines/WOSSearchEngine.searchengine/
> ;
>    CFBundleNumericVersion = 18907136;
>    CFBundlePackageType = BNDL;
>    CFBundleSignature = MTPX;
>    CFBundleVersion = "1.2";
>    NSBundleInitialPath = "/Users/griek/Library/Application Support/
> Papers/PlugIns/SearchEngines/WOSSearchEngine.searchengine";
>    NSBundleResolvedPath = "/Users/griek/Library/Application Support/
> Papers/PlugIns/SearchEngines/WOSSearchEngine.searchengine";
>    NSMainNibFile = Panel;
>    NSPrincipalClass = mtWOSSearchEngine;
> }
>
> while at runtime and just after downloading the bundle it looks like:
>
> dict: {
>    CFBundleExecutablePath = "/Users/griek/Library/Application 
> Support/Papers/PlugIns/SearchEngines/
> CiteseerSearchEngine.searchengine/Contents/MacOS/
> CiteseerSearchEngine";
>    NSBundleInitialPath = "/Users/griek/Library/Application Support/
> Papers/PlugIns/SearchEngines/CiteseerSearchEngine.searchengine";
>    NSBundleResolvedPath = "/Users/griek/Library/Application Support/
> Papers/PlugIns/SearchEngines/CiteseerSearchEngine.searchengine";
>    NSPrincipalClass = mtCiteseerSearchEngine;
> }
>
> I'm quite running out of ideas what is going on. The more because in 
> addition the gcc debugger seems to have problems with this on its own:
>
> BFD: BFD 2.16.91 20050815 internal error, aborting at /SourceCache/
> gdb/gdb-768/src/bfd/cache.c line 517 in bfd_cache_lookup_worker
> BFD: Please report this bug.
> The Debugger has exited with status 1.The Debugger has exited with 
> status 1.
>
> Anyone a clue of what's going on? Any help is appreciated!
> Alex
>
> _______________________________________________
>
> Cocoa-dev mailing list (<email_removed>)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/<email_removed>
>
> This email sent to <email_removed>

Related mailsAuthorDate
mlTrouble loading bundles at runtime Alexander Griekspo… Feb 6, 18:36
mlRe: Trouble loading bundles at runtime Jonathan Hess Feb 6, 23:12
mlRe: Trouble loading bundles at runtime Alexander Griekspo… Feb 6, 23:20
mlRe: Trouble loading bundles at runtime Bill Bumgarner Feb 6, 23:21
mlRe: Trouble loading bundles at runtime Bill Bumgarner Feb 6, 23:26
mlRe: Trouble loading bundles at runtime Alexander Griekspo… Feb 6, 23:32