Cookie Notice

Tuesday, 4 October 2016

Pick a Platform, any Platform – The Turn

Continuing on from our initial foray into creating an analogy between magic and development as outlined in our previous blog on “The Pledge”, in this post we want to cover the first part of the real magic.  We’ve already established (I hope) that Visual Studio is a great, maybe even the best, tool for developers.  We know we can write code fairly easily and create software of all different shapes and sizes for the Windows Platform.  But what about the magic?  For those of us old school developers who started in Visual Basic before it was even part of Visual Studio or even newer developers that see “Visual Studio” and only think “Software for Microsoft Windows” today’s post is for you.  We want to roll up our sleeves, show you that we have nothing under there and describe a little magic with Visual Studio.

Part 1 – The Pledge

Part 3 – The Prestige

The Turn

So, if you will watch my hands (at no time will my fingers leave my hands) you will see that using just Visual Studio I can now create, deploy and debug apps on Windows (no surprise there) and Android.  With a little help I can now create, deploy and debug apps on iOS and macOS as well.  With just a few magic words (written in the mystical language of C#) you can do it too!

Xamarin

The magic wand is Xamarin.  It is the tool that allows us to create multi-platform apps all with Visual Studio on a Windows device.  You aren’t creating some sort of HTML app that runs on all the platform, you are creating native apps with native user interfaces for all the platforms.  You have lots of ways you can create the magic too so the show should never get boring.  For the most part there is little to nothing else you need except in the case of iOS.  For that you need to have a macOS device of some sort (MacBook or MacMini will work) to do the compile.  However, it’s important to note that although the Mac is sitting there doing it’s job you are still writing the software, testing and debugging right on your Windows device, even for iOS…
The first thing you need to do is make sure you have Visual Studio 2015 installed.  Any edition will do.  The next step is to install Xamarin.  Another great thing is you can get started on this for nothing.  You can combine Visual Studio community edition with Xamarin and they are both free.

Platforms

With Xamarin you develop in multiple ways depending on your preference and needs.  A good majority of any code you might write is re-usable across all the platforms.  And you can write it all in C#.  In fact, in most instances you will find that doing the code in C# is easier than Objective-C, Swift and Java.  Things like Asynchronous programming are just easier with C#’s built in language level support.  Inside Visual Studio you can do your code behind using C# but still creating your UI using storyboards for iOS and XML for your Java and of course XAML for Windows.  Or, you can use Xamarin Forms and really bump up your re-usable code.  I attended a workshop a short while ago where we built an app in the space of a couple of hours using Xamarin Forms with a little help from James Montemagno, Principal Program Manger at Xamarin/Microsoft. Xamarin Forms uses XAML to design the UX but when you build the app for the different platform Xamarin translates all that work into native controls and apps so you don’t have a layered common generic app but rather an actual Native app with access to Native APIs.

My Breakthrough

I have written a lot of apps for the Windows Platform.  At last count it was over 80 apps.  But I have never written an iOS or Android app.  Being a .NET developer I just didn’t have the time to get up to speed on those platforms and still maintain my edge in .NET.  Xamarin destroys that wall and lets me look at my existing apps in a new light.  There is now no need for me to make that decision.  I can take existing apps and with a minimal amount of work prepare them for distribution on iOS and Android.  To me that is the real magic.  I have played around with XCode and Objective-C but to get the quality I expected was just not easy.  This removes that barrier and lets me move forward. 

Next Up – The Prestige

Now that we have shown Visual Studio to be both “normal” and magical I need to make the assistance re-appear, the Rabbit to disappear.  I need to conclude the magic trick.  To do that I’m going to take one of my existing apps written for Windows Phone 8.1 and move it to UWP/iOS/Android and document the experience.  Hold tight for the Prestige.  I’ll try to keep the language not too offensive and will hopefully help you experience the magic too!

No comments:

Post a Comment