A More Complete NativeScript Sublime Text 3 Build System

After attending a Hybrid Apps Meetup in Berlin recently where Sebastian Witalec gave this great talk on NativeScript I finally did try it out. This Sublime Text 3 workflow tutorial by T.J. VanToll was part of me getting started with {N} and although T.J.’s build system was a great starting point, I wasn’t really happy with having one line of code where I can swap out my device/emulator I want to build my app on.

The first option I tried was adding Variants to the Build System (one each for each virtual iOS device) but then they were all available in the global build system:

To avoid this pollution of the global build systems, I prefer adding the build systems to the *.sublime-project file:

Depending on how and where you start the instance of Sublime Text and what shell you are using you may run into problems with the PATH or ANDROID_HOME variables, see my comment on my gist. Nevertheless this should be a good starting point.

Note:
This build system is designed for OSX, if you want to use it for windows you’ll have to change the syntax, e.g.

"cmd": ["tns", "run", "ios"],

See the Sublime docs on how to add platform specific code to the same build system; if you want to keep it all in one file or are frequently moving between Unix and Windows.

If there are any bugs in my build system or if you want to make additions, feel free to fork my gist and get in touch on twitter.