Every time you create a new Xamarin.Forms project in Visual Studio for Mac you have to manually convert it to .NET Standard. The conversion is very straightforward and can be done with just a few steps:
Hopefully one day VS team will take care of it, till then, I decided to automate this process and created an add-in/extension for VS for Mac – Mutatio.
Mutatio – in Latin means change, transformation or exchange.
Mutatio can convert newly created or existing projects. Please keep in mind that there might be
NuGet packages that does not support .NET Standard 2.0, in this case you may see related exceptions.
In case you change your mind and you want to rollback,
Mutatio is making a backup of all the files it modifying and deleting under the project’s root directory within
mutatio_backup folder. So all you have to do is to copy the files back to your project and reload the solution.
One of the biggest challenges I met while development was related to reloading the project after conversion. Within VS for Mac after manually modifying the
*.csproj under the right click menu of the project there will appear a
Reload option, however I didn’t find a way to call this method programatically. Currently, the whole solution will be reloaded as a workaround. If you know how to solve the problem programatically I would really appreciate if you will share your knowledge by contributing or leaving a comment.
More details can be found on GitHub.
We live in a great time where technology evolves fast and we need to keep up with it if we want to stay relevant. Beside this, we also have to be productive, use the latest and greatest tools, implement the best available solutions and deliver on time. Following article mentions a list of most common mistakes we tend to do while using Xamarin.Forms.
Continue reading “Most common mistakes beginners make in Xamarin.Forms”
What can feel better than writing a code? Of course deleting it!
There are many good technical articles that explain why .NET Standard is great and why should we use it. My goal in this article is to demonstrate some benefits in practice.
If you didn’t switch yet from
Shared Projects to .NET Standard, I would highly recommend to do it. Most of the third party libraries are compatible and the switch is usually painless. After switching to .NET Standard you could benefit from reducing the code size and the amount of “hacks”. Let’s take a look on few practical examples. Continue reading “Reducing the amount of code by switching to .NET Standard”
Very often I hear questions like “Is there any Facebook SDK for Xamarin.Forms? Because there is one for Android Xamarin Native.”. This kind of questions can apply to different SDK that are compatible only with specific platforms and cannot be consumed directly in Xamarin.Forms. The answer to these questions usually is “If there is an available native Xamarin SDK it can be consumed in your Xamarin.Forms project. All you have to do is to create an abstraction like you would do with any other platform specific code.”.
As you might already understand, in this article we will create an abstraction over Xamarin.Facebook.Android and Xamarin.Facebook.iOS in order to display a native Facebook Login Button and handle the authentication related events in our Xamarin.Forms application.
Continue reading “Using Native Facebook Login Button in Xamarin.Forms”
Swagger is a very powerful tool that I highly recommend to integrate into your API projects. It will simplify and speed-up both the development and QA processes. This tutorial is going to demonstrate that. Just keep reading.
For this tutorial I assume that you should have a basic understanding of ASP.NET Core Web API and Xamarin.Forms. If you want to follow this tutorial while checking the source code you are welcome to clone this tutorial’s repo.
In this post we will create a simple ASP.NET Core API with Swagger, we will generate the API consumer code using NSwag and finally we will integrate it to our Xamarin.Forms application.
Continue reading “Using Swagger to automatically generate the client code”
Being lucky to develop a backend and a Xamarin.Forms clients on your own? Sooner or later you will have to debug the API calls and it might become painful. Unless, you will follow the next rules:
- Configure your API URL to run on 127.0.0.1 instead of a localhost:
// .NET Core Web.Api example
public static IWebHost BuildWebHost(string args) =>
- Configure your Xamarin.Forms API consumer to have a conditional URL base:
string apiUrl = null;
if (Device.RuntimePlatform == Device.Android)
apiUrl = “http://10.0.2.2:5001/api“;
else if (Device.RuntimePlatform == Device.iOS)
apiUrl = “http://localhost:5001/api“;
throw new UnsupportedPlatformException();
The problem with Android emulator is that it maps 10.0.2.2 to 127.0.0.1, not to localhost. However, the iOS Simulator uses the host machine network.
That should be it!
Many years ago when I was at high school, I wrote a bot for a web browser flags quiz game, where a flag of a random country and 4 different country names where shown to the player. It was fun!
So I created the same game for iOS and Android using Xamarin.Forms just for fun. It is open source and available on github:
This is what you get when an engineer creating a game without a designer. Luckily you can contribute if you have an idea on how to improve the UI/UX or if you want to add new features. I had a couple of them in my head:
- Learning game mode (without time or a game over)
- [X] game mode – where the flag image is covered by some objects that the player has to remove and/or etc.
If you are new to Xamarin.Forms or MVVM I would recommend to check the source code, it is touching the next interesting topics:
- ViewModel first navigation
- Custom fonts
Otherwise you are free to use the source code as you wish since it is under MIT license.