Updating Mobile Development Environment

On 20th July, Microsoft released Visual Studio 2015. This release of Visual Studio includes improvements in terms of IDE features, Language features and even changes in underlying .NET framework. Along with this, Microsoft is also releasing Windows 10 on 29th July, which will add Universal Windows Platform (UWP) development capabilities to Visual Studio. In this blog post, I’m going to cover the features that are most important for us i.e. mobile developers. Having said that, if you want to build UWP apps on RTM, hold on till July 29th, as the SDK and tooling for UWP will be released on the same day. You can find that information here.

Install Selection

You can think Visual Studio 2015 as the most complete mobile development IDE. You can build any kind of mobile applications which can run on Android, iOS and Windows devices. To setup your environment for mobile development, while installing itself, make sure you select your required tools. For example, here I’ve selected Xamarin tools to build native mobile applications. In this case, Visual Studio will install the necessary SDKs and libraries e.g. Android SDKs & NDKs with different API levels, Java SDK, etc…

VS 2015 Install

If you’re already a Xamarin developer, you may want to install Xamarin Studio, which needs to be installed separately by downloading Xamarin Installer from the site. With open sourcing of .NET and Roslyn, even Xamarin Studio is using some of its benefits. You can read more about it from Miguel’s blog.

Xamarin Integration & Project Template

Previously (VS 2013 or prior), you had to install Xamarin to get Xamarin specific project templates. With VS2015, if you select above option during install, you’ll have Xamarin project templates in File > New Project Dialog.

VS 2015 Project Templates

Note: The difference between Blank App (Native Portable) & Blank App (Xamarin.Forms Portable) is literal. That means, later one has Xamarin.Forms NuGet and integration in all projects. First one, just creates 4 separate projects without Xamarin.Forms dependencies.

When you create a Xamarin project, Visual Studio will ask you to sign into your Xamarin account to use different features according to license.

VS 2015 Xamarin

Developer (aka God) Mode

As I mentioned above, if you want to build UWP apps on RTM, you’ll need to wait till 29th July. And to enable Windows Store apps development and debugging on your machine, you’ll need to enable a ‘Developer Mode’. When you create a new project you’ll get following dialog which can take you to next dialog, where you need to select ‘Developer Mode’ and you should be able to test your apps. Do the same thing in your Windows 10 mobile device, if you want to debug apps directly on mobile.

VS 2015 - Developer Mode

VS 2015 - Developer Mode Enabled

Accessing Tools

This is not new as such to Visual Studio 2015, but I want to add it here for your reference. You can find all the tools and setting related to Xamarin and mobility under Tools menu. So, if you want to download new API Level (for example Android M Preview) or monitor your Android app’s performance on device using Android Device Monitor, you know where to look for. We’ll cover tools and features exclusive for Windows 10 in next post.

VS 2015 Tools

By the way, if you ever face any issues with Xamarin and need to contact support, Xamarin logs can help you to share more information about your issues with Support guys. Even, you can go through them and find issues/reasons. You can find them easily under Help > Xamarin

If you want to check where exactly platform SDKs are installed, you can find in Tools > Options and at two different selections

VS 2015 - SDK Location - 1

VS 2015 - SDK Location - 2

More Resources

Now, if you want to know more about Visual Studio 2015 and .NET Framework, Microsoft Channel 9 has Connect On-Demand series on it. Some of the most important videos are here

What’s new in C# 6
New Coding Experiences for C# and Visual Basic
What’s New for .NET 2015
Developing iOS and Android Apps in C# with Visual Studio
Xamarin.Forms: Leaveraging XAML to Build iOS, Android, and Windows Apps
Wearables in C#: Highlighting Apple Watch, Android Wear, and Microsoft Band
GitHub Extensions for Visual Studio

I’ll update tendulkar-uvāca series with new tools and technologies once they are released i.e. after 29th July. Till then, download the Visual Studio 2015 and enjoy the new IDE & tooling.

By the way, have I told you: You get Visual Studio 2015 Community Edition free for specific use cases and along with it, you get Xamarin Starter for free. If you’re a student, you can get more benefit through Microsoft DreamSpark program.

Namaste
Mayur Tendulkar

 

tendulkar-uvāca : Episode 2

In previous episode of tendulkar-uvāca, we’ve seen how we can setup our development environment using Visual Studio and Xamarin.
In this episode, we’re going to see how we can use emulators to test and debug our applications.

iOS simulators will get installed with XCode is installed.
For Android emulator, install Xamarin Android Player from here
Windows Phone emulators can be installed while installing Visual Studio 2013 Update 3.

Do let me know your feedback and suggestions.

Namaste
Mayur Tendulkar

Plugin 05: Accelerometer

In our series on plugins, today we’re going to cover plugin which can help us to work with Accelerometer sensor. This sensor is responsible to detect X, Y, Z co-ordinates of the devices. Using data received from this sensor, you can build games like TempleRun, where users can collect the coins by tilting the device.

There are different APIs for different platform and their usage is different too. First, lets see how we can use this sensor in different platform and then we’ll use plugin in Xamarin.Forms application.

Being Windows Runtime API, the API and its usage is same in Windows and Windows Phone. Here, you create object of the sensor and register for ‘ReadingChanged’ event. Whenever device position is changed, it is reported through that event and UI can be updated using Dispatcher.

In case of Android, it is again similar to Windows platform. Create object of SensorManager and register for SensorChanged event.

iOS is not any different. You create object of CMMotionManager and then listen to sensor for changes.

As you can see, for three different platforms the APIs are totally different. But with Plugins for Xamarin.Forms it becomes easy. You can use DeviceMotion plugin which can work across all these platforms. And the code for same looks like:

In this series on plugin we’ve seen how particular concept can be implemented in all the three platforms and how we can use plugin to make life easier. This will be be last post in this series, but there are many plugins available which you can explore and use in your projects. Do let me know if you want to cover any specific plugin. We’ll start with a new series in couple of weeks. Till then… happy coding :)

Namaste
Mayur Tendulkar

Plugin 04: FileIO

In continuation to blog posts in this series on plugins, today we’ll cover a plugin/library to perform FileIO.

There are different APIs on different platforms to perform FileIO. Having said that, Xamarin already makes life easier by implementing System.IO which is available in Android and iOS.

Following code can be used in Android to create a file and then read contents from it.FileIO - Android

Similarly, following code can be used in case of iOS application. FileIO - iOS

In case of Windows, using WinRT APIs, the case is little bit different as shown below:FileIO - Windows

Now to make life easier, there is a NuGet from Daniel Plaisted, which can help you to use same code on different platforms. You can find more information about the library from here: https://www.nuget.org/packages/PCLStorage/FileIO - Forms

This way, you can use one code (in C#) across all the three different platforms.

Hope you’re enjoying this series. Do let me know your feedback if you want to include any specific libraries/features.

Namaste
Mayur Tendulkar

Plugin 03: Phone Calling

In continuation to blog posts in this series on plugins, today we’ll cover a plugin to make phone calls.

As we understood before, all platforms support phone calling (just like emailing, texting, etc…) and Xamarin makes it easier with one common language – C#. However, developers still need to learn

In case of Windows Phone, one can initiate a phone call by using following code. In this case, Windows Phone has special class which allow developers to perform this task.

Screenshot 2015-02-23 10.53.12

In case of Android, developers can use ‘Intent’ and ‘URI activation’ to start a new phone call.

Screenshot 2015-02-23 10.56.09

In case of iOS, same concept of URI activation can be applied. As shown below in the code, developers can create a URI with telephone number and it will launch default application to make a phone call.

Screenshot 2015-02-23 11.13.09

Now, in case of Xamarin.Forms developers can use same Messaging Plugin for Xamarin and Windows plugin to implement phone functionality across the platforms.

Screenshot 2015-02-23 12.31.23

This way, developers can utilize the power of plugins to write one code which can work across different platforms, without bothering about underlying APIs.

Namaste
Mayur Tendulkar

One Code To Rule Them All, but Why?

Windows: runs on more than 90% desktops, laptops, netbooks and nowadays it runs on kiosks, smart devices, phones and these days gaming console. However, developers always faced challenge to target all these devices and deliver ONE app, which can run on all these devices. There were differences in APIs, kernel, core services and what not.

When .NET was released, Microsoft tried to solve this problem by introducing .NET Framework on desktop and .NET Compact Framework – a subset of full .NET Framework *modified* for smart devices. Then, there was yet another .NET Framework for yet another class of devices called .NET Micro-Framework. So, developers had three different .NET Frameworks to target different class of devices, yet someone can’t just copy/paste code from one device app to another. Libraries compiled for one device may not work on another (e.g. app compiled for Windows Mobile *may* fail if ran on desktop – as both used to be PEs). But, for someone like me, it was a good start. I could write apps for mobile phones or desktop using the same language that I know i.e. C# or VB.NET.

Later, Microsoft introduced a very nice concept of Portable Class Libraries, which allowed developers to share code between various platforms.

image 

The limitation was, PCLs are binaries which give you ‘least common denominator’ of APIs available across platforms you selected. So, if you select .NET Framework and Windows 8, APIs which common to these two platform will be selected. And, if you wanted to do maximum code-reuse, your best bet is to follow MVVM like patterns, put models/view models in PCL and create app for views. So, the project structure will look like:

image

PCLs solve some of the issues in best possible way. But when it comes to Windows & Windows Phone, there are lot of similarities like UI, API set, programming model. Here we need some solution which can give maximum code reuse and go beyond PCLs.

Welcome to Universal Apps

image

Universal Apps allows you to build app with maximum code sharing which can work on Windows and Windows Phone (and Xbox in future). When you create Universal App, template creates 3 projects for you as shown below:

image

Now, you may say that it looks pretty similar to above mentioned solution which use PCLs.  Yes, it looks same, but there are internal differences:

When you create Universal App, you can share UI, Media, Code, XAML, etc.. using Shared Project. Now, Shared project allow you to share *code* between projects, whereas PCL allow you to share *binary* between projects. That also means, you can’t use #if.. #then compiler switches in PCLs and can’t write (or rather get benefit from) platform specific code. So, it also means that, when you build the project, you don’t get *.Shared.dll or something and it is not *referenced*, rather during build the code will be automatically included from shared project into individual projects. You can spot the difference in icon here.

image

With Universal App, you can share UI as well. In next screenshot you can see that there is almost no difference in Windows page and Windows Phone page.

image

image

Just tell me which one is which and I’ll give you a gift when we’ll meet next time Smile. Now rather I typing here, following slide will speak a lot:

image

After all this, if you *package* these projects, you get APPX which you can submit to the store.

This is certainly a nice move from Microsoft considering developer audience. For consumers, they can now buy app on desktop and can use it on phone. And for me this is true ‘ONE MICROSOFT’ Smile

There are many new announcements happened at //build/ to follow them and If you want to know more about Windows Phone 8.1 Features, Universal App FAQs, do visit blogs from my friends:

Namaste,

Mayur Tendulkar

Cross-Platform. Hybrid or Native?

Recently I had to build an app for our company (zevenseas) which can work across all the platforms i.e. Windows Phone, Windows 8, iOS (iPhone, iPad) and Android (Phone and Tablet). I started looking for various options like Titanium, Icenium, PhoneGap & Xamarin. Considering the options I had, I chose two best solutions Icenium and Xamarin. But like many, I was confused about which one to use & when, one being hybrid and other native. So, I used and tested both and here are my findings in this post.

Experimenting with Xamarin – A native solution

I started using Xamarin (build on top of Mono) since February 2013 and I’m loving it. Just think about writing apps for Android/iOS/Mac using the language that you’re using since years – C#. The best feature that I can see which Xamarin provides is one solution to build them all. Just think about having one solution, which has all the required projects & dependencies at one place. Everything in one IDE (Visual Studio), one solution and in one repository, built using one language. This is AWESOME. The other most important feature for me is Portable Class Libraries (PCL). Think about having your Data Access Layer, Business Logic Layer, Models, etc.… into PCL and then referring it into various different applications. Just create UI layers. 100% code re-use. Isn’t it? So, think about project structure like this:

image

Other awesome feature which I liked about Xamarin is, their releases aligned with release of .NET features, iOS and Android. You can use LINQ, Async/Await, PCL in your cross-platform project. One more thing to mention here, Xamarin provided support for iOS7 as soon as it got released. Pretty amazing.

The challenges with Xamarin

I can see some challenges with Xamarin & yes, those can be addressed. First one is third-party SDKs equivalents and controls. Recently Xamarin is coming up with their components-store and I’m waiting for few SDKs and components to appear in it. Perhaps, this can be a great opportunity for some folks to build and sell their components/controls. For example, I wanted to build mobile app to fetch data from SharePoint. For Windows Phone, there is SharePoint SDK for Windows Phone. Being lazy, I wanted that same SDK as Xamarin component. It is doable. No doubt. But if somebody can provide it to me, or provide solution to migrate these kind of SDKs to Xamarin I’ll be happy. (btw, Xamarin has something called scan my code which analyses the code and tells you how much of it can be reused across platforms).

Capture

In case of controls (like Telerik, Infragistics, ComponentOne, Mindscape and Syncfusion), it would be great if I can port/use existing controls (without reinventing the wheel) written in .NET; in my cross-platform solution. I know, it is going to take time, but still.

Second challenge that I found is if I want to build highly touch intensive app like which includes drawing/animations/etc…. manipulating that in C# can be difficult. Same can be achieved with existing JavaScript libraries in Icenium. Although there is MonoGame for game development, works just like Xamarin products and built on top of Mono.

Playing around Icenium – A hybrid solution

I have fair understanding of JavaScript/JQuery and have used JQuery Mobile to build mobile web-apps. So, getting used to Icenium was damn easy. The great thing I loved about Icenium is, I can use same code (UI, DAL, BAL, etc…) for all the platforms. Plus, I can run any simulator and test the app LIVE. When I say live means, just make a change in HTML/CSS/JS, save and the it affects the app in simulator. Too good. Plus these simulators are pretty fast. In case of Android emulator, if I start it, I can easily go for a walk, have a cup of tea and still emulator is booting-up on my machine. I’ve ‘one of the best machine’ – thanks to zevenseas.  (P.S. Xamarin has nothing to do with Android emulator. It uses Android’s native emulator i.e. AVD etc.…, which by default slow. You can try Intel HAXM & Intel Atom based Android images in this case)

image

Being hybrid app platform, I can use all existing JavaScript libraries including Jquery mobile, Kendo UI or what not. The list is endless. This is LEGEN—wait for it DARY… The challenge with Xamarin (third-party libraries) can be solved here. Other feature which I liked the most is, you can build the app and run or test it on Android or iOS device without developer account. It uses something called Icenium Ion. Because *i think* provisioning profiles is pathetic with Apple. Microsoft and Google are way better in this case. However, remember that at the end you need developer account to publish the app. You can delay this, but can’t skip.

image

The challenges with Icenium

I found some challenges when dealing with Icenium. First, if you already have your existing logic in C# (in case of Xamarin, PCL is the best solution), then porting it to hybrid app (JS) can be time consuming affair. You may need to re-write. But this re-write can help you to use that code across platforms. Second, the simulators are not active simulators and has some limitations. Which means, you can’t use hardware buttons like back/home/menu etc… on Android/iOS. Keyboard inputs work from real keyboard connected to development machine. You also can’t test most of the Cardova plug-ins.

Apart from these challenges, I found both Icenium and Xamarin good options to build cross-platform solutions. So, the question is when to use what?

  Icenium Xamarin
Use existing C# Knowledge and code
Incl. Async/Await, LINQ, PCL, etc…
 
Use existing JS knowledge and code
Inc. Jquery, JQMobile, KendoUI, etc…
 
Cross-Platform
(Windows Phone/8, Android/iOS/Mac/Desktop/XBOX)
Android & iOS

Edit: I just found that Icenium as IDE allows you to build apps for Android, iOS. However, the same code can be used to build for Blackberry and Windows Phone externally i.e. like using Visual Studio to build XAP (Windows Phone package). Using respective build process. Thanks to Lohith for pointing out my mistake.

When it comes to documentation and support, both of these solutions are good. Xamarin uses default .NET APIs which you already know. In case if you’re looking for platform specific API, while going through Xamarin docs, you can navigate to Apple or Android documentation. Basically, Xamarin has one-to-one API mappings/bindings (just for example, it may be different. I don’t know internals). So, it makes life easier. Icenium on the other hand, is all JavaScript. You may need to check with each JS library vendor for documentation. Support is good as both the solutions have active forums and twitter handles to ask questions.

I will not talk about performance. I haven’t built similar kind of application using these two solutions to check performance. Hence, I can’t comment on this point.

So far I’m loving both of these solutions to build cross-platform applications and I’ve my own reasons to choose right-one at right-time. Do you? Do let me know if you need any further information.

Namaste,

Mayur Tendulkar