Trouble loading bundles at runtime
Trouble loading bundles at runtime
- Subject: Trouble loading bundles at runtime
- From: Alexander Griekspoor <email@hidden>
- Date: Wed, 6 Feb 2008 17:36:39 +0000
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;
}
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 Support/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@hidden)
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:
This email sent to email@hidden