Re: IB Plugin help
Re: IB Plugin help
- Subject: Re: IB Plugin help
- From: Kevin Cathey <email@hidden>
- Date: Sun, 5 Apr 2009 16:16:38 -0500
Hi Jon,
Here are my responses to your responses to my responses :):
[1] INSTALLING THE PLUGIN
There are obviously two modes for using an IB Plugin: developing it,
and then actually using it as if it was just another plugin on the
system. In the case you are developing the plugin, the best way to do
this comes by default when you created the IB plugin project: just hit
Build and Go and Xcode will pass along information to IB to load the
development version of your plugin. Again, this works out of the box.
But as you asked, how do we get a plugin from development into
"installation" mode where I don't have to be debugging my plugin from
Xcode to use it? There are a few ways of doing this of course. One way
which I use to develop plugins is to build what is called a
distribution root. A root is a built version of your project that,
when the build is finished, is put in a folder (the "Installation
Build Products Location", or "DSTROOT" which is by default "/tmp/
PROJECT_NAME.dst") that has a hierarchy of subfolders that mimics the
layout on disk. The layout is determined by each Xcode target's
"Installation Directory" (INSTALL_PATH). For example, let's say I have
a MyPluginProject Xcode project that has the two standard IB plugin
targets, MyPlugin for the plugin, and MyFramework for the framework.
For the framework target, I set the Installation Directory to "/
Library/Frameworks" (set by default). And for the plugin target, I set
the Installation Directory to "/Library/Frameworks/
MyFramework.framework/Resources" (also set by default).
Now, from the command line, I use the CLI to Xcode called xcodebuild.
If I run the "install" command, then Xcode will build my project,
create the folder specified by my DSTROOT, and then install each of
the built targets into the appropriate subfolders based upon their
Installation Directory. The "install" command might look like this:
----------------
cd MYPROJECTDIRECTORY
sudo xcodebuild install -configuration Release -target All
----------------
This invokes xcodebuild to build the "All" target (added by default in
IB plugin projects) of the project in the CWD using the Release
configuration. If I then look in /tmp, I will see the following
folder: "MyPluginProject.dst". And inside of that folder, I get the
following layout of folders:
/tmp
/MyPluginProject.dst
/Library
/Frameworks
/MyFramework.framework
... other framework stuff
/Resources
/MyPlugin.ibplugin
... and it's
contents
Then, to "install" the distribution root on my system, all I need to
do is the following command:
----------------
sudo ditto /tmp/MyPluginProject.dst /
----------------
And this will copy the contents of the distribution root folder in
"/", effectively placing each item exactly where it needs to go. At
this point, the framework and plugin are installed, and if I open up
IB, go to the Preferences, and add the plugin from /Library/
Frameworks, then I'm done.
So, to review. To install a plugin, assuming I started with standard
IB plugin template, I do the following:
(1) Set the Installation Directory for the plugin and framework to
where it should be installed. The framework, by default, will be "/
Library/Frameworks", which is good. The plugin, by default, will be "/
Library/Frameworks/MYFRAMEWORK.framework/Resources". That also is
fine. If you change the name of your framework, however, be sure to
reset the installation directory.
(2) From the directory from plugin Xcode project lives in, build a
distribution root by running the following: "sudo xcodebuild install -
configuration Release -target All"
(3) To install the built root, run: "sudo ditto /tmp/
MYPROJECTNAME.dst /"
(4) In IB, under the Preferences, add your plugin by finding the
framework in /Library/Frameworks.
(5) Enjoy!
But what if I want to change some things about your plugin later on?
Do you have to build a root and install each time you want to check a
change your are working on? No! If you change your plugin and want to
test it quickly, you just hit "Build and Go" like you did when you
first developed the plugin. Xcode will pass this information to IB,
and IB will use your development version, NOT your installed version.
How does it know the difference? When you run from Xcode, Xcode sets
up the current working directory and then passes a flag that IB uses
to open your plugin. Since the CWD is set to your build products
folder, it uses the the plugin from there instead.
This way, you can work on your plugin for awhile, making changes and
testing in IB. Then, when you are satisfied, you can build a root,
install it, and then go along your merry way using the new version
until you want to change it again.
To read more about what distribution roots are, check out the
following link:
http://developer.apple.com/documentation/developertools/conceptual/XcodeProjectManagement/070-Building_Products/building.html#/
/apple_ref/doc/uid/TP40002693-SW101
[2] THE PLUGIN AND FRAMEWORK IDENTIFIERS
As you've probably noticed, your bundle identifiers for the plugin and
the framework are the same. This can potential lead to some problems.
NSBundle refers to bundles globally by their _unique_ bundle
identifier. If two bundles share the same identifier, there is the
potential for problems. For example, as you saw, IB claimed that a
required framework was your ibplugin, and not the .framework. This is
because since the plugin and framework share the same identifier, when
IB looks up the name of the bundle corresponding to your required
frameworks, it gets the ibplugin, not the framework.
You should just make the bundle identifier for framework and the
ibplugin unique. After changing this, do a clean of your project and
rebuild, and also unload old versions of your plugin from IB. Then you
should be fine.
[3] THE DEFAULT IMAGE
I think the reason this wasn't working might be related to the
response to [2] above.
Hope that clears some stuff up.
Kevin
--------------------------
Kevin Cathey
_______________________________________________
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