Subject:   Plug-ins don't load if not running from ProjectBuilder
Date:   2002-12-27 05:14:16
From:   anonymous2
Response to: deployment candidate fix but didn't work

The reason plug-ins load when running from ProjectBuilder but not when running the app directly is because it doesn't work in ProjectBuilder either. At least not as you expect.

The problem is this call in discoverPlugins:

NSBundle *plugin = [NSBundle bundleWithPath: name];

You're trying to load a bundle from a path but you only supply a file name. In this case you're looking for "GrayscaleFilter.plugin". Where does NSBundle look for that file? In the current working directory which ProjectBuilder conveniently set to the build directory. If you look in the build directory you'll see GrayscaleFilter.plugin,, and intermediate files. So NSBundle finds the file and loads it. But it loads the _wrong_ version of GrayscaleFilter.plugin. It doesn't load the one that's inside ImageApp in the PlugIns folder!

The simplest way to fix this is to load the bundle with a full path and not just the file name. So replace the line above by these:

NSString *pluginPath = [path stringByAppendingPathComponent:name];
NSBundle *plugin = [NSBundle bundleWithPath: pluginPath];

I though NSRunAlertPanel() was extremely useful when debugging an application outside of ProjectBuilder.