Automatically Exporting Assets from Sketch into Xcode.
Switch branches/tags
Nothing to show
Clone or download

Automatically Exporting Assets from Sketch into Xcode.


Today, Bohemian Coding released SketchTool. It’s “a command-line app for exporting pages and slices out of .sketch docs.”

Many people use Sketch in their Mac and iOS development workflow. Previously, the process involved making changes in Sketch, exporting them, moving them into Xcode Asset Catalogs, then running. However, with SketchTool, this can all be done automatically.


Watch the screencast.

Download the files used in the screencast.

Installing Sketchtool

You can download the latest version of Sketchtool from Bohemian Coding’s website. To install it, run "".

Alternatively, use the following lines of code pasted into Terminal to do effectively the same thing:

curl >;\
cd sketchtool/;\
cd ../;\
rm -r sketchtool/;\

Setting up your Sketch files

Many people have their project organized differently, but I prefer to have all Sketch documents in a folder at the root of the project’s directory. I usually name it “Graphics Resources”. This is what I’ll be using in the screencast.

Then, use artboards and slices for the assets you want to export. For example, in my app icon Sketch document (AppIcon.sketch), I have an artboard made for each size of the icon. It’s a modified version of the iOS app icon template bundled with Sketch 3.

Build scripts

In Xcode, you can add a new run script build phase. Make sure this new build phase occurs before “Copy Bundle Resources”, which copies in Image.xcassets.

The contents of the script should be like:

sketchtool export artboards "$PROJECT_DIR"/"Graphics Resources/AppIcon.sketch" --output="$PROJECT_DIR"/"$PROJECT_NAME"/Images.xcassets/AppIcon.appiconset --formats="png"

This should be modified and extended for your uses, and I may try to work out a way where this can be done more easily.