Skip to content

A sample project that shows how to connect a Sketch 3 plugin to a binary helper app

Notifications You must be signed in to change notification settings

abynim/Sketch-PluginHelper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Sketch-PluginHelper

A sample project that shows how to connect a Sketch 3 plugin to a binary helper app written in Swift.


Test the example plugin

  1. Extract the contents of this repository in your plugins folder.
  2. Use the Make Selection Red plugin to see an example of custom UI launched by the plugin.

The Helper app

  1. Open _source/PluginHelper.xcodeproj in Xcode.
  2. SketchPlugin.swift is a reusable file which you can drop into your own helper app to communicate with Sketch App.
  3. AppDelegate.swift contains code to instantiate SketchPlugin, and show the initial window once set up.
  4. Check out Main.storyboard and HelloViewController.swift to see how the custom UI is set up and how it uses SketchPlugin.swift to load data from and send data to the Sketch App.

Hints

  • When developing your Helper app, make sure you have only one <Helper>.app file on your system. The plugin script uses the [NSWorkspace openFile: withApplication: andDeactivate:] method to send commands to the helper app. If there is more than one <Helper>.app file on your system (even in different folders), NSWorkspace will be confused about which app bundle it should use to launch the commands, and may use an older version than expected. When you Archive your helper app, remember to Move (not Copy) it into the script folder. If you've created multiple archives, either delete or zip them so they aren't directly accessible. Also remember to Clean your Xcode project before testing archived app bundles to make sure the test build generated by Xcode is deleted.

Contributions

If you fork this repository and end up making some useful updates, please do send me pull requests so I can include your work here and give you credit.

Help and Questions

If you run into issues or have any questions, please reach out via Twitter @abynim.

Credits

This example uses XPerformSelector to use the Objective-C-only performSelector method from Swift.


MIT License © Aby Nimbalkar. I'm on LinkedIn and Twitter.

About

A sample project that shows how to connect a Sketch 3 plugin to a binary helper app

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published