///Cross Platform Mobile Development

Native App Cross Platform Development – Choosing an Approach

Mobile development is a highly specialised area. Today, iOS and Android devices share over 90% of the smart-device market. Both arguably offer similar features yet have different development and deployment environments. Apple provides Xcode for developing and deploying iOS apps to iTunes. iOS developers code using Objective-C or (now) Swift. Android is based on the Open Source Java Development Kit. Android developers typically develop apps in Java and deploy apps to Google Play. These approaches and environments are similar in many ways but also different and require different skillsets. The market typically demands mobile apps on both iOS and Android devices. Optimising development and maintenance costs is a significant factor and is often underestimated. Effective cross platform development has been a generic Holy Grail for decades. Modern computer languages and Web technologies have bought us closer to realising cross platform development. The objective of this article is to help you make an informed decision for selecting a Native App Cross Platform Development Approach.

Cross platform solutions, such as Phone Gap and Apache Cordova, utilise standard web technologies, including HTML5, CSS3, and JavaScript. Fundamentally, these approaches utilise a WebView (dedicated browser) that points to a responsive design web site. A hybrid approach is possible utilising the WebView with native application components. In many cases a simple WebView or hybrid approach is effective and may very well suit the needs of simple applications. However, when the native look and feel, performance, off-line operation or access to device facilities, such as Geo Location, is required a WebView or hybrid approach may fall short. So, what are the alternatives? We are going to briefly look at and compare two fundamentally different Native App Cross Platform Development approaches: Xamarin and NativeScript. They are fundamentally different yet with the same goal – Develop great native apps efficiently.

 Xamarin

Xamarin is a C# platform and toolset that developers use to write native Android, iOS, and Windows apps with native user interfaces from a shared codebase. Developers can code in C# and may code the UI in C# or XAML – an XML-based mark-up language developed by Microsoft. Xamarin provides a generic layer called Xamarin Forms that allows developers to develop apps in a generic manner that is platform independent. A Xamarin Forms app looks like and behaves like an iOS, Android or Windows app from the same codebase. Xamarin compiles C# to native code and therefore runs very fast. You get access to C#, Xamarin and NuGet libraries which provide extensive functionality. Over 1 million developers use Xamarin in more than 120 countries. Xamarin was purchased by Microsoft in March of 2016.

Microsoft Visual Studio is the recommended Xamarin development environment and is now available on Macs. Xamarin Studio is also available for Macs and is an excellent toolset similar to Visual Studio. Both development environments are highly productive and offer significant tooling including IntelliSense editing, source control, package and library management, debugging and release management. To deploy iOS apps and run the iOS simulator access to a Mac is required to host Xcode.

NativeScript

NativeScript is a cross-platform development approach for native iOS and Android apps using web tools without WebViews. NativeScript uses TypeScript with Angular 2 to get truly native UI and performance while sharing skills and code with web development. Angular 2 provides 2-way data binding and connectivity hooks. You get 100% access to native APIs via JavaScript and reuse of packages from NPM, CocoaPods and Gradle. NativeScript is an Open Source product and is backed by Progress.

There are many options for setting up a NativeScript development environment. The NativeScript Tutorial provides a basic installation. Microsoft’s Visual Code Editor is suggested and provides IntelliSense features. Development environment configuration is open, i.e. your choice. Visual Studio / Xamarin provides almost everything one needs to develop and release apps. There are many development environment choices for web development and should not be underestimated. NativeScript uses the JavaScript Virtual Machine (JVM) which is available on each platform. There is a small runtime overhead which by all accounts has minimal performance impact. When developing and you save your code the run time environment does a ‘Just In Time’ compile and updates your Android Emulation. Code changes are very fast! As per Xamarin, to deploy iOS apps, access to a Mac is required to host Xcode.

Here is a summary of some important features you should consider.

Xamarin NativeScript
C# on mobile devices, code in 1 language TypeScript (can use JavaScript)
XAML UI mark-up option Angular 2 data binding and connectivity
Xamarin Forms for generic development Web based generic development
Native compiled apps Native apps running on JVM
Native UI controls Web Controls
Code sharing 90% Code sharing 90%
Native performance – no JavaScript Near Native performance – JVM
Visual Studio – a powerful environment Open development environment
C#, NuGet and 3rd party libraries Native Script, JavaScript, 3rd party libraries
Web Integration support available Web Integration is inherent with Angular
Backed by Microsoft, freely available Open Source, backed by Progress
Established with a large user base New with a smaller user base
Extensive support groups Emerging support groups

So which way do you go?

Consider NativeScript if:

  • You want to reuse code between your web projects and mobile projects
  • You have investments in web technologies
  • You are comfortable writing TypeScript
  • You are invested in Angular 2 or moving to Angular 2
  • You prefer Open Source collaboration
  • You want to use 3rd party open source components

Consider Xamarin if:

  • You have developers familiar with C#
  • Your skill base is C# and would rather not retrain in Web technologies
  • You have no investment in Angular and no plans to do so
  • You prefer NuGet as your package manager of choice
  • You are invested in Visual Studio
  • You don’t like command line, and would rather do things visually
  • Extensive support from Microsoft and the community

Both technologies are very good and well supported. For me the decision to which way to go should be based on the technologies and skillsets you currently have and where you are headed. If you are invested in Microsoft technology and happy then Xamarin could be the right choice. On the other hand, if you are invested in Web technologies then NativeScript could be the right choice.

By | 2018-01-08T15:28:56+00:00 December 10th, 2017|News|