Hot Reload in Xamarin
Designing the UI was never too friendly in Visual Studio while you are working on Xamarin apps. It works a bit under MacOS but in Windows it isn’t too friendly. You have to build the project just to see a small change you made in UI. This is quite time wasting, and frustrating, if the machine you are using is not fast enough to let Visual Studio run smoothly.
Then comes the Hot Reload to rescue. Hot Reload is really helpful to quickly see the changes you are making in your XAML files. No matter if it’s a small change of color, or addition of a whole complex stack layout, your app running in emulator / simulator / or a real device reflect the changes quickly.
The time we had to waste on testing the UI changes reduced to almost none as after using hot reload, we don’t have to keep building the app again. We did rebuild the app again and again, but only to test the functional changes.
Enabling Hot Reload in Visual Studio 2019
You should meet the following requirements to use hot reload in Visual Studio;
Using Visual Studio 2019 16.4 or higher
Or Visual Studio 2019 for Mac 8.3 or higher
Xamarin Forms 4.1 or higher
- Go to Options in Tools menu
- Select Xamarin from the list at left
- Select Hot Reload
- Enable the checkbox “Enable XAML Hot Reload for Xamarin.Forms”
- Click on OK to apply changes and dismiss the dialog box
You can also locate this setting by searching Hot Reload in Options dialog box.
- Click Preferences in Visual Studio menu
- Click Xamarin Hot Reload under Projects
- Enable the check box Enable Xamarin Hot Reload
Now, you are all set. Just run your app in emulator / simulator or on a physical device. Whatever changes you are making to your UI in XAML, will be immediately updated in your app.
Note that there are certain limitations to using hot reload. It can only hot reload your UI changes done through XAML, don’t expect the functional changes to be reflected.
Find out details on limitations at this link;
Hot Reload is time saving feature. Even with its limitations doesn’t matter, because most of a mobile developer’s time spent on designing a great UI which is consistent across an array of devices of varying display sizes. So if functional changes are not loaded using Hot Reload, who cares.