<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Cocoa Tutorial: Adding Plugins to a Cocoa Application</title>
	<atom:link href="http://www.cimgf.com/2008/09/17/cocoa-tutorial-adding-plugins-to-a-cocoa-application/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.cimgf.com/2008/09/17/cocoa-tutorial-adding-plugins-to-a-cocoa-application/</link>
	<description>Taglines are for Windows programmers</description>
	<lastBuildDate>Mon, 26 Jul 2010 16:50:30 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
	<item>
		<title>By: Chris Hanson</title>
		<link>http://www.cimgf.com/2008/09/17/cocoa-tutorial-adding-plugins-to-a-cocoa-application/comment-page-1/#comment-807</link>
		<dc:creator>Chris Hanson</dc:creator>
		<pubDate>Thu, 18 Sep 2008 07:37:24 +0000</pubDate>
		<guid isPermaLink="false">http://www.cimgf.com/?p=272#comment-807</guid>
		<description>&lt;p&gt;A couple of points to keep in mind.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;The term on Mac OS X is &quot;plug-in&quot; with a hyphen, capitalized as &quot;Plug-in&quot; and inter-capped in APIs as &quot;PlugIn&quot;.  cf. Apple Publications Style Guide, the old CFPlugIn API documentation, the &quot;Plug-ins&quot; section of the Get Info panel in the Finder, and the Contents/PlugIns directory of the application you&#039;ve embedded a plug-in within.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;A plug-in &lt;strong&gt;doesn&#039;t&lt;/strong&gt; need to have a main class or nib defined.  It could supply some other metadata, for example via its Info.plist file, or via subclassing of known classes, that the host application could use to locate appropriate plug-in facilities.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Don&#039;t use -[NSBundle pathsForResourcesOfType:directory:] to locate embedded plug-ins, just look for packages with an appropriate extension in [[NSBundle mainBundle] builtInPlugInsPath].&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Don&#039;t use &quot;bundle&quot; or &quot;plugin&quot; as your plug-in path extension; use something unique to your application. After all, your application can&#039;t load just any plug-in, and other apps can&#039;t necessarily load yours.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;On Leopard, use -[NSBundle loadAndReturnError:] to load plug-ins. This will tell you why a plug-in failed to load; for example, it may not have been compiled for your current architecture or with the right garbage collection flags.  You can use -preflightAndReturnError: and -executableArchitectures to check basic things like architecture match in advance of loading.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Unloading plug-ins that use Cocoa is very hard, and may not necessarily be feasible.  For example, you would need to guarantee that all literal NSString instances that came from a loaded plug-in were no longer in use.  Similarly, any caches that may be maintained on a per-class basis may need to be cleared, including those within Cocoa.  Depending on what your plug-in does, it may not be able possible to unload.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Finally, if you&#039;re building a plug-in API, don&#039;t just look in your application&#039;s embedded plug-ins folder, look in its Application Support folder in all available domains as well.  Your users shouldn&#039;t be putting extra plug-ins inside your application; they&#039;ll get lost when you do a Sparkle update, for example.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;7.1.  Also for development purposes it can be useful to tell your application an additional path or set of paths to load plug-ins from via a user default.  This should usually be searched &lt;em&gt;before&lt;/em&gt; your standard set of paths, because then you can find the in-development version of a plug-in you&#039;re working on in Xcode and use it in favor of the release version installed on your system.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>A couple of points to keep in mind.</p>

<ol>
<li><p>The term on Mac OS X is &#8220;plug-in&#8221; with a hyphen, capitalized as &#8220;Plug-in&#8221; and inter-capped in APIs as &#8220;PlugIn&#8221;.  cf. Apple Publications Style Guide, the old CFPlugIn API documentation, the &#8220;Plug-ins&#8221; section of the Get Info panel in the Finder, and the Contents/PlugIns directory of the application you&#8217;ve embedded a plug-in within.</p></li>
<li><p>A plug-in <strong>doesn&#8217;t</strong> need to have a main class or nib defined.  It could supply some other metadata, for example via its Info.plist file, or via subclassing of known classes, that the host application could use to locate appropriate plug-in facilities.</p></li>
<li><p>Don&#8217;t use -[NSBundle pathsForResourcesOfType:directory:] to locate embedded plug-ins, just look for packages with an appropriate extension in [[NSBundle mainBundle] builtInPlugInsPath].</p></li>
<li><p>Don&#8217;t use &#8220;bundle&#8221; or &#8220;plugin&#8221; as your plug-in path extension; use something unique to your application. After all, your application can&#8217;t load just any plug-in, and other apps can&#8217;t necessarily load yours.</p></li>
<li><p>On Leopard, use -[NSBundle loadAndReturnError:] to load plug-ins. This will tell you why a plug-in failed to load; for example, it may not have been compiled for your current architecture or with the right garbage collection flags.  You can use -preflightAndReturnError: and -executableArchitectures to check basic things like architecture match in advance of loading.</p></li>
<li><p>Unloading plug-ins that use Cocoa is very hard, and may not necessarily be feasible.  For example, you would need to guarantee that all literal NSString instances that came from a loaded plug-in were no longer in use.  Similarly, any caches that may be maintained on a per-class basis may need to be cleared, including those within Cocoa.  Depending on what your plug-in does, it may not be able possible to unload.</p></li>
<li><p>Finally, if you&#8217;re building a plug-in API, don&#8217;t just look in your application&#8217;s embedded plug-ins folder, look in its Application Support folder in all available domains as well.  Your users shouldn&#8217;t be putting extra plug-ins inside your application; they&#8217;ll get lost when you do a Sparkle update, for example.</p></li>
</ol>

<p>7.1.  Also for development purposes it can be useful to tell your application an additional path or set of paths to load plug-ins from via a user default.  This should usually be searched <em>before</em> your standard set of paths, because then you can find the in-development version of a plug-in you&#8217;re working on in Xcode and use it in favor of the release version installed on your system.</p>]]></content:encoded>
	</item>
</channel>
</rss>
