NativeScript -> The new Awesome way to build Android, & IOS applications

I've been developing applications for a wide variety of platforms (you name it, I've probably touched it) .   Over my long career in computer development and devops, this includes a lot of mobile apps.    I've done hybrid apps in Phonegap/Cordova.   I've done pure native apps on the Android; and I've done apps on a Nokia Maemo/Meego, I've even done apps on old Windows Mobile 6.   So I've had some experience with a lot of mobile platforms.

So, I now have this brand new application that I have decided to write; and of course the majority of my early beta adopters will be on IOS; but the majority of my customers I believe will be on Android.  Which means, I need cross platform from the beginning.      I then spent several weeks evaluating several newer & and re-evaluating several older cross platform systems to try and decide which one to use to tackle this project in.        After most my research was done, I had narrowed it down to pretty much React Native.    Unfortunately, React Native does not have any Android bindings yet.    So, I continue looking around and while looking at Telerik's offerings, I saw a link about this all new cross platform project called NativeScript.   Figured, might as well and so I installed what was the first public release v0.9 and ...  fell in love with it.

I LOVE that it is totally cross platform for both Dev and Deployment, it runs on Mac, Linux and Windows out of the box.   And It already supports deployment to both IOS and Android, with Windows Phone bindings coming some time in the future.  Being so new it is missing a lot of things that other platforms might already have; but overall it is surprisingly feature complete.

I LOVE that it has a common library and a common screen building language that works on all the platforms; BUT it has the ability to customize them several different ways for the platform your are targeting in the event you need to make customizations per-platform. Example:

<span class="blob-code-inner"><span class="pl-s">&lt;Page&gt;&lt;TextField ios:editable='False' android:editable='True' /&gt;&lt;/Page&gt;</span></span>

As you can see, I can put in a ios: or android: prefix and have customizations for values per platform.   I can also have a file.android.xml and/or file.ios.js to make specific versions of a screen or js file per platform (there are also other valid variations for screen size/dpi).

I LOVE that I am not having to create a THUNK layer anytime I want to talk to any Android or IOS api.   NativeScript allows me to call Java code (on Android) and X Code (on IOS) functions from inside JavaScript.  Example for Android: (Java Documentaton)

var path = '/tmp/test.data';
var javaFile = new java.io.File(path);
if (!javaFile.exists()) {
  console.log("File Exists");
} else {
  console.log("File Does Not exist");
}

Do you see what I did their -- I called a native android java constructor: new java.io.File(<passed in a Javascript variable>);

I don't need to create a custom function on the android side for each time I need to do something in Android native land.  Then compile that with either the SDK or NDK and then use some sort of thunking/message layer to call it.    I can now CALL any native Java code right from my JavaScript and use the Variables and Functions as is.    (Same applies to the IOS layer)

Now the really awesome news is the entire NativeScript stack is open source.   You can download any of the pieces from github and build, create, add issues, create pull requests on any of the pieces you need to build a NativeScript IOS or Android application.

1. Cross Platform Library - This is the common library so I can do things like  var fs = require('file-system'); if (fs.exists('blah'))...  -- this code has the common and has the device specific modules so it works for every platform.
2. Android-Runtime - This is the code that has the JavaScript v8 engine on the Android Platform
3. IOS-Runtime - This is the code that runs the JavaScript Core engine on the IOS platform.
4. Android-metadata-generator - this is what creates the JavaScript bindings to the native Android Java.
5. IOS-Metadata-Generator - this is what creates the JavaScript bindings to the native IOS platform Objective-C.
6. NativeScript Command Line Interface - This is what you use to build, deploy, test your application.

Now if all you are interested in building apps; you really don't have to worry about the above repos; you just need to follow the basic install instructions for your platform at nativescript.org.

If you use VMWare or VirtualBox  or Vagrant see my next post which I will link here shortly.

 

4 thoughts on “NativeScript -> The new Awesome way to build Android, & IOS applications

  1. Dareenzo SK

    Hello Dude,

    I just want to congratulate you for the work in automating the build-deploy process for native script. It's a really neat work.

    In addition I'd just like to request any tutorials or tips and tricks. I can see you're really keen and kinda like somewhat advanced in using, so if you could share all the goodies with us that'd be great.

    Regards,
    Dareenzo

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *