Home

Awesome

npm npm npm

NativeScript Real Time LiveEdit Ability

A NativeScript module providing real time development for Android. This version is for v2.3.x of the Android Runtimes. Please note this project USED to be called NativeScript-LiveSync, but to eliminate the confusion between the Telerik LiveSync and my LiveSync, I decided to rename my project.

License

All this code is (c)2015-2016 Master Technology. This is released under the MIT License, meaning you are free to include this in any type of program -- However for entities that need a support contract, changes, enhancements and/or a commercial license please contact me at http://nativescript.tools.

I also do contract work; so if you have a module you want built for NativeScript (or any other software projects) feel free to contact me nathan@master-technology.com.

Donate Patreon

Differences between Telerik LiveSync & Master Technology LiveEdit/Pro

Master Technology released the LiveEdit project in v1.00 of NativeScript; In the version v1.2.0 of the NativeScript command line tools; Telerik has now released a limited LiveSync (or what I consider a DeadSync command. :grinning: ). The differences from my LiveEdit and Telerik's LiveSync is substantial enough that I will continue to use and maintain my version for the foreseeable future. The good news is they are catching up, they have fixed several major issues in each release and as they release newer versions they get a lot closer in feature parity.

Pros of Telerik's LiveSync:

Cons of Telerik's LiveSync:

Con's of Master Technology's LiveEdit:

Pro's of Master Technology's LiveEdit:

The iOS side is currently just a simple DUMMY WRAPPER so that any usage you use on the Android side will not cause any issues when you deploy to your iOS devices/emulator.

Real Time LiveEdit Demo

1st Video Showing off Real Time LiveEdit Development Ability 2nd Video Showing off Real Time LiveEdit Development Ability

VERY IMPORTANT NOTES

This plugin includes the latest release runtimes WITH the liveedit patch included into it.

If you want to compile the runtimes your self; you can clone the latest runtime; switch to the release branch, and then manually patch it with my above patch (pull request 92), and then install the runtime following the latest documentation. http://docs.nativescript.org/running-latest

You can also run the latest nightly runtimes from http://nativescript.rocks, and the LiveEdit patch is auto-applied to the nightly master before it builds it.

Please note the watcher specifically does NOT watch the App_Resources folders, mainly because this folder must be built, as these are compiled resources.
In addition the device code itself does not have any code to start watching any new folders when they are added; restarting the app will allow it to start watching it. I have a billion other things on my list that affects me more. So this is a very low priority to actually code it up, I would gladly take pull requests that fixes this, if you find this oversight too annoying.

I realize XMLLint is a pain to install on windows, so I have included all the needed files on the NativeScript.rocks site.

If you use the new tns clean, or tns platform add/remove to reset your platform folder; this deletes resets the entire platform folder, meaning you loose the custom liveedit runtime. You will have to de-install and re-install the plugin to continue using it.

Installation

Run tns plugin add nativescript-liveedit

Upgrading

You need to de-install the prior version of LiveEdit, then install the new version. Run tns plugin remove nativescript-livesedit then run tns plugin add nativescript-liveedit

Prerequisites:

Run npm install jshint -g

If you are using TypeScript; you should install tslint; run npm install tslint -g

If you don't have xmllint already on your machine; you will need to install it. (Windows users: http://xmlsoft.org/sources/win32/)

Usage & Running

On your development machine you need to open a command prompt to your main application folder; and type node watcher which will start the utility that handles verification and pushing new files to the devices or emulators.

To use the liveedit module you must first require() it in your application.

var liveedit = require("nativescript-liveedit" );

You should as a minimum put this in your app.js like so:

var application = require("application");

// ---- ADD THIS LINE ----
require('nativescript-liveedit');
// -----------------------

application.start({ moduleName: "main-page" });

Then this will activate at the start of the application and work for the entire time, also notice the removal of the "./" in the cssFile. I'm not sure why Telerik put a ./ for the app.css as it is unneeded.

Magic Restart Files

Changes in these files will automatically cause the application to restart on the device or emulator.

Get the LiveEdit object

var liveedit = require('nativescript-liveedit');

Methods

addModelPageLink(Page, Model)

Parameters

ignoreFile(Page)

Parameters

restartFile(Page)

Parameters

enabled(value)

Parameters

debugMode(value)

Parameters

getAppName()

This will return the package name in the from the AndroidManifest

getAppVersion()

This will return the VersionName from inside the AndroidManifest

restart()

This will fully restart the application -

checkForEmulator()

This will check to see if the app is running on a emulator

checkForDebugMode()

This will check to see if the app was signed with a debug key (i.e. debug mode)

reloadPage()

This will reload the current page

isSuspended()

This will tell you if the application is suspended. (i.e. some other app has focus)

currentAppPath()

This will return the current application path.