7.0 Plugin SDK Changes - realmacsoftware/RWPluginKit GitHub Wiki

The following is a list of changes that were made for the launch of RapidWeaver 7.0

Controlling whether a page can be created

In RapidWeaver 7, we're allowing you to decide if a new page can be created using your plugin. You could use this to provide different pricing tiers for example (more pages for more $$), or to ensure that only one instance of your plugin ever exists in a project.To do this, implement the +canCreateNewPage:currentPages: method and return either YES or NO. If you return NO, you are expected to populate the error reference with a reason why the page creation was denied.For example, to limit the number of instances of your plugin in a project to three you might do something like this:

static NSUInteger allowedNumberOfPages = 3;

+ (BOOL)canCreateNewPage:(NSError **)errorRef currentPages:(NSArray *)currentPages { if ([currentPages count] == allowedNumberOfPages){ *errorRef = [NSError errorWithDomain:[NSBundle bundleForClass:[self class](/realmacsoftware/RWPluginKit/wiki/NSBundle-bundleForClass:[self-class) bundleIdentifier] code:0 userInfo:@{NSLocalizedDescriptionKey : @"Some error message here"}]; return NO; } return YES;}

The currentPages array will contain only the pages in the current document that use your plugin.

Providing a different icon for the "Add Page" menu

Now that RapidWeaver 7 has a dark sidebar, you might like to provide a different icon for RapidWeaver 7's "Add Page" menu. To do it, simply add an icon file to your plugin named the same as your existing RWPluginIconSmall icon, but append _addmenu to the end of the filename:

Handling migrations

In RapidWeaver 7 it is possible to change where your add-ons are stored. If the user changes this location and chooses to move any existing add-ons in the process, your plugin will be notified:

+ (void) willMigrateAddonLocation

If you'd like to be notified if the user migrates their addon folder to a new location, implement this method and do any necessary work before returning.

Please note: if the user decides not to move existing add-ons then you will not be notified of a change in location.

Memory Management

As of RapidWeaver 7 Public Beta 1, RapidWeaver will no longer call -unloadPluginOnDocumentClose, as we have improved the memory footprint of RapidWeaver. If you were previously using -unloadPluginOnDocumentClose to do any teardown, you should move that teardown to -dealloc, as we’ve fixed the issue that blocked dealloc from being called.