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.

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.

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.

iOS: For iOS you will need a mac somewhere on your network to connect to and then you can use our Remoted iOS Simulator for Windows. This is available for all editions of Visual Studio.

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!

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:

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.

I’ve heard different answers so: I don’t want to pay for a Mac, can I build and deploy iOS apps from Linux? If so what does that process look like?

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.

Platform Specific libraries. Having a views library which can be packaged as Nuget package and be used where applicable Using https://t.co/4rln9fcnn5 and Xamarin.iOS.

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.

The app lifecycle, specially on Android, is much different. There you go :-)

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.

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!

Timely since I just started working with Xamarin.1. Which VS components are actually needed to develop Android and iOS? (Answer: Just install everything including UWP even if you aren't developing UWP. If you don't install all VS will be buggy! Found that out the hard way.)

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.

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!

I'm relatively new to Xamarin.forms but the one thing i keep seeing around is a NavigationService. So what is one? Should we use one? And do you have a good example of one?

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.

Should I use a cross-platform MVVM framework? Why, or why not? Is it useful even if I'm only working with 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.

Is it going to be possible to make cross platform desktop apps? Ie run on both Mac and Windows? Is it possible to use XAML for macOS apps or only storyboards? Are the lack of windows app development going to hold back vs for Mac to be like4like with vs for windows?

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!