James Montemagno
James Montemagno

Live, Love, Bike, and Code.

Live, Love, Bike, and Code

Share


Tags


Getting Started with Xamarin and Xamarin.Forms Q&A

Every day when I open my inbox or look on GitHub there is always a question or ten for me to answer. I recently got a nice long email from Clifton with a lot of questions and I thought that instead of emailing him back directly that I should write up a blog post with all of my answers for the world to enjoy and add some common questions I get all the time.

2d48e149d28ea2b2ff0328e5cd54c8e2_Xamarin-Inc..zpoh_xamarin-logo-hexagon-blue

Clifton wrote in and said he is investigating cross-platform development with Xamarin and Xamarin.Forms as it is one unified application platform between iOS, Android, and UWP for all form factors. On top of that he is a C# developer that has a lot of experience with XAML in the past.

My first recommendation even before answering his questions would be to read through my "What Xamarin Developers Ought to Know" from last year. It is a great article packed with information.

Also I would recommend that you:

Now here come the questions:

Can I run all emulators for iOS/Android/UWP on Windows 7/8/10 with Visual Studio 2015/2017?

I would likely recommend going with the latest and greatest: Windows 10 and Visual Studio 2017 (Any Edition including Community). This will give you the best compatibility with all of the different platforms and .NET Standard. Additionally, if you want to do UWP development you will need Windows 10.

In general, Visual Studio 2017 and Windows 10 will be the best experience.

As for emulators:

Now that said, for iOS development it is important and required that you have a macOS device to do full compilation and debugging. This is a requirement as Xcode only exists on macOS and also it is part of the developer agreement you sign with Apple. You can use your macOS for remote build, compilation, and debugging through Visual Studio 2017. Here is some great documentation.

Don't forget that you don't need a Windows machine to do iOS and Android development. You can do all of it inside of Visual Studio for Mac!

Can I use an inexpensive older Mac (lion) that I can get from Craigslist?

You can buy an older device, but you should ensure that it is able to run the latest version of macOS. This is important because new versions of Xcode only support the latest version and the previous one. So as of this blog post that would be High Sierra and Sierra.

And yes, you will absolutely need a macOS device to do your final compilations and ship to the store, but remember it doesn't have to be the most expensive model. I would of course recommend setting up Continuous Integration and Deployment with VSTS or AppCenter.

My application will require some real-time 3D graphics. I'll mostly be working with cubes, spheres, polygons, and some other slightly more complicated shapes.

No need to go down the OpenTK route, I would look at UrhoSharp for 3D graphics as it works cross-platform and integrates with Xamarin.Forms. It is the latest and greatest.

For 2D graphics I would go with SkiaSharp as it is equally as awesome for 2D and integrates great with Xamarin.Forms!

We actually talked about SkiaSharp on Merge Conflict Episode 66

Additionally, the API is consistent and cross-platform in line with all of the platforms we support.

JavaScript can manipulate SVG and its elements. Do you have libraries that can manipulate SVG and its elements?

There are several libraries out there, but actually you can do all of this with SkiaSharp and here is a great tutorial.

With Xamarin, will I have access to .Net's HttpClient and .Net's Sockets services, which will integrate seamlessly into Xamarin.Forms on all platforms?

Yes, absolutely! We use HttpClient right out of the box! On iOS/Android they go through the native stacks, but you don't have to worry at all because we handle that for you. Just use HttpClient and it will just work! Here are some great docs for working with HttpClient:

On Merge Conflict Episode 37, we actually talked a lot about Http and TLS:

Even more questions!

So, that did it for Clifton, but I figure why not open this up to the community.

So I asked on Twitter:

Here we go:

I love Immo! This is a great question. I would say it is important to know that your .NET and C# knowledge all transfer extremely well to iOS/Android/macOS development with Xamarin. We outline great code sharing strategies that are compatible with all platforms. I like to use MVVM, so if you are coming from a UWP/WPF world it will be very similar.

Know that with Xamarin there are two approaches. Xamarin Native, which is sort of like developing an app for WPF and WinForms. You develop the UI twice natively, but share all your business logic. This gives you 100% API access, 100% of the UI and of course the best performance.

Xamarin.Forms offers up a cross-platform user interface that is based on XAML or C#. This works across iOS, Android, UWP, macOS, and others supported by the community. This XAML is similar as it is XAML, but different as the controls and names are a bit different. However, picking it up is easy and we have great documentation on it.

As far as I know that is not possible. A macOS device is required to build and compile your iOS applications as part of the developer contract that you sign with Apple. Additionally, this is where all of the build tools live with Xcode, simulators, provisioning and more. Make your life easier and pick up a Mac Mini so you can properly debug your app on the simulator or device. Trust me.

For Android there is no issue here as Google ships tools on both Windows and macOS. Xamarin integrates deeply into them with both Visual Studio and Visual Studio for Mac.

Xamarin and the community do a lot of great work creating "Bindings" for iOS and Android libraries so you can access them from C#. All of ours are open source on our Components GitHub page.

We work closely with the community to create "Plugins for Xamarin and Windows" that abstract platform APIs into a single cross-platform API for developers. Things such as preferences, geolocation, taking a photo, audio, etc. You can find a full list on GitHub.

This is well documented, check it out.

We outline all of this on our code sharing strategies documentation, but essentially it is simply and ONLY use .NET Standard 2.0! It gives you everything you could possibly want and more for sharing code.

On Merge Conflict we talk all about this:

I have a subscription to Blue Bottle Coffee specifically their Origins subscription. Every two weeks I am greeted with a delicious 12oz bag of coffee. I brew most mornings in a Chemex, but I switch it up with a ceramic Hario v60 or Aeropress. May I also recommend another podcast I do, Coffeehouse Blunders, where we often chat coffee!

When installing Visual Studio 2017 you should only need the Mobile development with .NET workload:

XamarinWorkload

However, to ensure you have all the UWP and .NET Standard goodness I would install:

This is what I have installed on my computer today.

Xamarin (sometimes called Xamarin Native), enables developers to create fully rich iOS, Android, macOS, watchOS, tvOS, and Windows applications in C# and Visual Studio with 100% API coverage of each platform in C#. You develop the UI natively for each platform, but share all your business logic which on average is 60-80% of your application. This approach gives you 100% API access and 100% of the UI and of course the best performance.

Xamarin.Forms offers up a cross-platform user interface that is based on XAML or C# and sits on top of Xamarin Native itself. This works across iOS, Android, UWP, macOS, and others supported by the community. This XAML is similar as it is XAML, but different as the controls and names are a bit different. However, picking it up is easy and we have great documentation on it.

TraditionalvsForms

It is really easy to blend the worlds using Xamarin.Forms Native Pages, which allows you to easily add Xamarin.Forms pages to Xamarin Native application.

With Xamarin you have access to 100% of APIs on each platform and can leverage our binding system to bring in any iOS or Android library into your C# app. We have done tons of them for you already on our Xamarin Components GitHub page, but you can do it yourself with these great docs for iOS and Android.

Almost Done

I thought we were done with questions and then I woke up to so many good ones!

With Xamarin.Forms there is a NavigationService built right in! As long as you have a NavigationPage you can push pages onto the stack. You can also do modals at any time. Here is our full documentation.

page-types

There are a lot of MVVM frameworks out there. Xamarin.Forms includes one right in the box with what should be everything you need (it is all I need and use including a dependency service and messaging center). I would recommend watching Episode 5 of The Xamarin Show: MVVM & Data Binding with Xamarin.Forms.

There are a lot of other ones out there that work with Xamarin including MVVMCross, MvvmLight, and Prism. They all offer different things based on your needs. I wrote a good blog post on them for the the Xamarin Blog.

Jim was able to chime in on this tweet, but think of it like this:

Visual Studio 2017 for Windows:

Visual Studio for Mac:

The core tools and environment of the main OS live on that main OS. You can still open the projects and solutions from either IDE, just the design/compilation part.

Great question and I have already blogged a ton about it!:

Ads:

In App Purchase is always tricky and if you need deep deep integration you should really handle each platform and do what is best practice on each. For my apps I created a Billing Plugin for Xamarin and Windows that does everything cross platform.

Fin

That's it! Thanks to everyone that wrote in and feel free to startup a discussion below!

Copyright © James Montemagno 2018 All rights reserved. Privacy Policy

View Comments