- NativeScript is free and open source
- NS renders UIs with native platform rendering engine, no web views.
- Installation: NativeScript CLI install needed on the machine – http://docs.nativescript.org/start/quick-setup
- Windows installer – http://docs.nativescript.org/start/ns-setup-installer
- If your machine already has Android SDK installed then you’ll need to manually install NativeScript following the steps on the quick-setup page
- Windows intaller needs – Java Development Kit, Nodes.js, Android SDK pre-installed
- Complete the installation by following all the instructions above
- tns command from CLI
- tns create HelloWorld –template nativescript-template-tutorial to create Helloworld app
- Go to the app folder – cd HelloWorld
- Running the app:
- tns run android:
- You must have at least one AVD (Android Virtual Device) configured on your development machine for this command to run your app up on an Android emulator. If you don’t have one installed currently go ahead and set one up now.
- creating new virtual android emulator:
- Open android sdk manager from start menu – You have installed as part of the pre-requiresites for NativeScript
- Check all the system images are installed for future use or else click the install packages button at bottom right corner.
- Create Andrios virtual devices:
- Install HAXM for accelaration – https://software.intel.com/en-us/android/articles/intel-hardware-accelerated-execution-manager
- Complete the creation of emulators by clicking start button – check to see if there are any errors.
- If there are no errors the emulator will open up
- Execute the run command again to run your app on android emulator
- Can run multiple emulators at the same time:
- tns device command lists all devices
- choosing a device by – tns run android –device 2
- to run all connected devices is by – tns run android
- tns run ios
- Tns run won’t stop until ctrl+c as the app refreshes as you change the code
- Changing colour schemes – http://docs.nativescript.org/ui/theme#color-schemes
- When you add a new dependency you need rebuild the app from scratch
- Ref – http://docs.nativescript.org/tutorial/chapter-1
- tns run android:
Builidng a real-world app:
- login.js: code-behind:
- frameModule for navigation
- UserViewModel is for the login
- exports.loaded page binding is important for any parameter passing to work
- login works from now
- As a best practice, testing for a platform with an if check is the way to go when you have a small number of platform-specific changes to make. If, on the contrary, you have big, entirely different chunks of code for iOS and Android, you might want to go with platform-specific code-behind files—e.g.