A sample project that shows how to connect a Sketch 3 plugin to a binary helper app
JavaScript Swift Objective-C
Switch branches/tags
Nothing to show
Clone or download
abynim Merge pull request #3 from robert-smith-07/successful-build-xcode-7.3…
…-swift-2

Successful build in Xcode 7.3/Swift 2
Latest commit 0359943 May 16, 2016
Permalink
Failed to load latest commit information.
_source Successful build in Xcode 7.3/Swift 2 May 16, 2016
lib Minor tweaks Mar 18, 2015
Make Selection Red.sketchplugin Initial commit Mar 18, 2015
README.md Update README.md Jun 18, 2015

README.md

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.