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.
Also I would recommend that you:
- Listen to my podcast Merge Conflict
- Listen to the Xamarin Podcast
- Checkout the Xamarin Blog
- Read through all of our Amazing Documentation
- Signup for Xamarin University for the best way to learn (lots of great free stuff!)
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:
- UWP: I run apps on my desktop, no need for an emulator there
- Android: A few options are available. If you NEED hyper-v on then you would need a device or the Microsoft Android Emulators if you don't then I suggest the Intel HAXM hardware accelerated emulators from Google. They are amazing and what I use. Here is our full guide to setting up emulators.
- 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!
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.
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:
I am drafting a blog: Getting Started with Xamarin Q&A. Hit me with your questions!— James Montemagno 🙈 (@JamesMontemagno) February 22, 2018
Here we go:
Coming, from a Windows WPF/WinForms world, what are the most important things I should know upfront?— Immo Landwerth (@terrajobst) February 22, 2018
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?— Sam Ferree (@sam_ferree) February 22, 2018
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.— Amr Yousef (@amrfarid140) February 22, 2018
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 :-)— Miha Markic (@MihaMarkic) February 22, 2018
This is well documented, check it out.
Can you not create a PCL on .net standard anymore? Why or why would you not want to? Which is preferable?— Patrick Goode (@PatrickGoode) February 22, 2018
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:
- 85: All I Want To Do is Multi-Target
- 77: dot net pack holiday
- 50: We Have Standards
- 38: One Library to Rule them All
My tip would be to make sure you like coffee! Learning any new platform is a journey and you need to be prepared to put the hours in.— Craig Barrie (@csharpdvlp) February 22, 2018
i've been bug-bashing a Xamarin project today and had 3 espressos before lunchtime.
My question is, do you grind your own beans? :)
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.— MikeWatson (@MikeWatsonNC) February 22, 2018
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.)
When installing Visual Studio 2017 you should only need the Mobile development with .NET workload:
However, to ensure you have all the UWP and .NET Standard goodness I would install:
- Universal Windows Platform development
- .NET desktop development
- ASP.NET and web development
- Azure development
- Mobile development with .NET
- .NET Core cross-platform development
This is what I have installed on my computer today.
"What is the difference between Xamarin and Xamarin.Forms?"— Ed Snider (@edsnider) February 22, 2018
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.
Is it possible to implement a YouTube video player in #XamarinFoms?— Johan Villanueva (@johanfvn) February 22, 2018
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.
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?— Ieuan Walker (@IeuanTWalker) February 22, 2018
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?— Santiago Quiroga (@santiagoqrg) February 22, 2018
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.
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?— Jeffrey Kranenburg (@jwknz) February 23, 2018
Jim was able to chime in on this tweet, but think of it like this:
Visual Studio 2017 for Windows:
- UWP / WPF / WinForms
- Android + Android Wear/Auto/TV
- iOS (need mac for final compilation and debugging via remote connection) + tvOS / watchOS
- ASP.NET / ASP.NET Core / .NET Core
Visual Studio for Mac:
- Android + Android Wear/Auto/TV
- iOS + tvOS / watchOS
- ASP.NET / ASP.NET Core / .NET Core
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.
How to include ads/iap cross platform with forms? Also how to do a good architecture with forms?— Raphaël BECK (@rphbck) February 22, 2018
Great question and I have already blogged a ton about it!:
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.
That's it! Thanks to everyone that wrote in and feel free to startup a discussion below!