| Article: |
Plug It In, Plug It In | |
| Subject: | Plug-ins don't load if not running from ProjectBuilder | |
| Date: | 2002-10-21 18:25:30 | |
| From: | anonymous2 | |
|
When I run the app from projectbuilder, the filter menu is loaded with the plugins, but when i run the app from the finder, the menu is blank…
|
||
Showing messages 1 through 3 of 3.
-
deployment candidate fix but didn't work
2002-10-22 10:25:54 psheldon [View]
-
deployment candidate fix but didn't work
2003-05-29 09:19:01 anonymous2 [View]
In some cases, build style will make some problems, but not this one.
The problem is caused by a small bug in the code:
we get the plugin by:
plugin = [NSBundle bundleWithPath: name];
and we go the name by enumerate the objetc returned by:
[[NSFileManager defaultManager] directoryContentsAtPath: path]
You will find that the name variable only contains the name of the bundle, but not the path. So the application has to find the bundle in the default directory. And apparently, the envionment setting of running within PB and as a standalone application is different, so it makes our application behave differently.
The solution is add a statement on the first of second while block:
name = [path stringByAppendingPathComponent: name];
You will find that it works fine now.
Good luck. -
Plug-ins don't load if not running from ProjectBuilder
2002-12-27 05:14:16 anonymous2 [View]
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, ImageApp.app, 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.



There was some entendre about superuser stuff with mention of root, so I did sudo pbxbuild install to gain a successful build where, when I hadn't, I got permissions denied and failed build.
But, the deployment didn't go where I had put it in projectbuilder, so I couldn't click on it to see whether it would see the plugins.
The apps used to work from a click in the build folder, so I think this working hypothesis that deployment was all that important for our level was overly optimistic and that hacking away at how to deploy just might be sour grapes anyway.
I am siezing on another hopeful working hypothesis in my lateral thinking, that the solution to your problem might also solve my problem of actually making plugins plural.
When I simply drag files with .plugin into Application Support plugins aren't seen as having a principle class, somehow, unless I am running from the project that generated them. I checked this with my version of plugin app and Mikes.
So, this is just an idea, a step along the way, not the answer. I try to remember that victory only comes to the frustrated.
;-)