Hot Reload for Xamarin.Forms comes to Rider

The Rider team has been hard at work, and we are happy to announce that Xamarin.Forms XAML Hot Reload is coming in Rider 2020.1!

In this post, we’ll see how this makes developing our Xamarin apps more enjoyable. We’ll also walk through some of the limitations of XAML Hot Reload, as well as list some of the XAML fixes and improvements in Rider 2020.1.

What Is Xamarin.Forms XAML Hot Reload?

Xamarin.Forms XAML Hot Reload allows us to make XAML edits during debugging and see those changes reflected immediately in our running application. XAML Hot Reload works on Android and iOS platforms, but is currently not available for Universal Windows Platform (UWP) apps or macOS apps.

Any changes to XAML will affect the UI, but all other application states will be maintained. This includes navigation state and in-memory state. In other words: we can iterate faster while not losing our place within our app!

Getting Started

Download & install the latest Rider 2020.1 EAP, which now comes with Hot Reload. That’s it!

Xamarin.Forms Hot Reload is part of the latest Xamarin.Forms packages. In this post, we’ll be using the Todo solution found in the Xamarin.Forms Samples, for those who may want to follow along.

1.-Todo-Solution

With this sample app, we’ll need to open the Todo solution and unload the UWP app. UWP apps do not support Hot Reload and cannot be built in non-Windows environments, so let’s get rid of it.

Hot Reload In Action

The Todo project comes with three XAML views: TodoItemPage, TodoListPage, and App.

2.-Todo-Views

We’ll be looking at two of the views specifically, TodoItemPage and App, to show what works and what doesn’t.

Opening the TodoItemPage view, we can see references to labels, text boxes, a toggle, and a few buttons. 

3. TodoItemPage XAML

Let’s move some of the UI elements around to see how Hot Reload works, making sure we are running our application in Debug mode.

5. hot reload in action

As we can see, when moving the UI elements, the iOS emulator flashes and reloads the XAML changes immediately. The behavior works exactly the same within the Android Simulator.

Now let’s see a limitation of the Hot Reload feature utilizing a different view. In the App view, we can see two settings for primaryGreen and primaryDarkGreen found in a resource dictionary.

While the colors are defined in XAML, they are used in C# and set in the constructor of our app. Changes to the color settings, while in XAML, will not be reflected until we restart our debugging session.

Known Limitations

While this feature is powerful when designing Xamarin.Forms applications, there are a set of known limitations that we should consider. These limitations are with the technology itself, not with Rider.

  • Some target platforms currently do not support Hot Reload, primarily, UWP and macOS.
  • Any structural changes to the project will not be reflected during Hot Reload, for example adding NuGet Packages or refactoring files.
  • Using the linker will cause Hot Reload to fail.
  • Hot Reload cannot reload changes to C# code. Any code-behavioral changes will require a rebuild and restart.

Read more about the limitations of XAML Hot Reload in the official Microsoft Documentation.

General Improvements and Bug Fixes

While XAML Hot Reload is an enormous quality-of-life improvement, Rider 2020.1 also brings some other smaller improvements and bug fixes that should make our XAML work much more pleasant.

From all of us Xamarin lovers at JetBrains to the XAML folks out there: we hope you try out the latest Rider 2020.1  EAP features. Your feedback is welcome!

About Khalid Abuhakmeh

Khalid Abuhakmeh is a Developer Advocate at JetBrains, focusing on .NET, Azure, and web development technologies. He has been in the business of creating software for nearly 16 years as a writer, open-source contributor, and leader. His hobbies include science, movies, languages, and travel. Follow Khalid on Twitter or check out his personal blog for more great .NET content.
This entry was posted in How-To's and tagged , , , . Bookmark the permalink.

2 Responses to Hot Reload for Xamarin.Forms comes to Rider

  1. What about hot reload for WPF applications?

    • Hello Emanuel. I believe WPF is not supported by Xamarin.Forms Hot Reload. The Rider IDE cannot do much since the Hot Reload is part of the library itself. There are third-party libraries that may be able to support hot reload but their results may vary.

Leave a Reply

Your email address will not be published. Required fields are marked *