uno icon indicating copy to clipboard operation
uno copied to clipboard

[HR] Hot reload not working on VS Code. [MAC OS Silicon]

Open saent-x opened this issue 1 month ago • 11 comments

Current behavior 🐛

Hello!

I am having issues getting Hot reload not working on Vs code. Uno templates is updated to the latest. and I am using .NET 10 on a Macbook, but when running the app the change events are not picked up by the app but are picked up by the Uno Hot reload Output. Also I am using C# Markup.

This issue is slowing down development and bad for DX.

https://github.com/user-attachments/assets/55aa3314-1f90-424e-8535-3e208869e549

Expected behavior 🎯

The hot reload should pick up changes and show the events.

How to reproduce it (as minimally and precisely as possible) 🔬

Reproduced in the attached video

Workaround 🛠️

===> cf. https://github.com/unoplatform/uno/issues/21857#issuecomment-3634142042

Renderer 🎨

  • [x] Skia
  • [ ] Native

Affected platforms 📱💻🖥️

iOS

Uno.Sdk version (and other relevant versions) 📦

"Uno.Sdk": "6.4.24"

IDE version 🧑‍💻

vs code

Anything else we need to know? 💬

N/A

saent-x avatar Nov 16 '25 17:11 saent-x

Able to repro and specific to iOS @saent-x does it works on your side if you target the desktop TFM ?

dr1rrb avatar Nov 18 '25 22:11 dr1rrb

Yh it does work on my side with desktop. IOS doesn't work. By the way I'm using IOS 26.1. I did a repro via a video. I can add more context if necessary...

saent-x avatar Nov 18 '25 23:11 saent-x

I think the simulator isn't picking the changes up.

saent-x avatar Nov 19 '25 00:11 saent-x

Yes I was suspecting that the hot-reload is not being initialized properly by uno.

But (to give more details of investigation) then using


using Uno.UI.DataBinding;

namespace HRwCSMarkup2;

public sealed partial class MainPage : Page
{
    public MainPage()
    {
        var button = new Button().Content("Click me");
        button.Click += OnButtonClicked;

        this
            .Background(ThemeResource.Get<Brush>("ApplicationPageBackgroundThemeBrush"))
            .Content(new StackPanel()
            .VerticalAlignment(VerticalAlignment.Center)
            .HorizontalAlignment(HorizontalAlignment.Center)
            .Children(
                new TextBlock()
                    .Name("MyTextBlock")
                    .Text("Hello world!"),
                button
            ));
    }

    private void OnButtonClicked(object sender, RoutedEventArgs e)
    {
        ((Button)sender).Content = new MyClass().GetText();
    }
}

public class MyClass
{
    public string GetText() => "Hello from MyClass";
}

If it was only init of HR in uno, changing text of the GetText() would have work anyway :/

dr1rrb avatar Nov 19 '25 15:11 dr1rrb

Hello everyone, let me add some context. I have the exact same issue and I think it is not related to the simulator because I have issues with MacOS Desktop, so, it is not the simulator and is not iOS related, I assume is a general bug for Mac devices either using VS Code or Rider (the one I Use)

As you may see on the attached image, each time that I try to make a change on my XAML Code I get a "Compilation Errors" but there are no errors from my code.

As I said before, Im not using an simulator because this is a desktop app.

Image

dgalo9 avatar Nov 19 '25 15:11 dgalo9

I think it is not related to the simulator because I have issues with MacOS Desktop, so, it is not the simulator and is not iOS related, I assume is a general bug for Mac devices either using VS Code or Rider (the one I Use)

Thanks for you report @dgalo9, but actually I think it's not related to the original bug report. I was able to get HR to work properly on desktop target from my mac yesterday and @saent-x confirmed it's working also on his side on desktop.

I opened a new issue for your report https://github.com/unoplatform/uno/issues/21893

dr1rrb avatar Nov 19 '25 17:11 dr1rrb

Thanks @dr1rrb I couldn't make it work on Mac Desktop. Not even after updating the Uno plugin to the latest version (released on yesterday).

Also thanks for the new opened issue. Best regards.

dgalo9 avatar Nov 19 '25 21:11 dgalo9

WORKAROUND

Workaround to get it to work without debugger attached, in you csproj, add

    <ItemGroup>
        <TrimmerRootAssembly Include="System.Collections.Immutable" />
    </ItemGroup>

Edit: This workaround actually works only for XAML based applications, not for CS4markup: For those the update occurs, but the UI is not refreshed.

cc. @saent-x

dr1rrb avatar Dec 09 '25 20:12 dr1rrb

WORKAROUND v2

A more complete workaround is, still in your csproj, to add:

	<!-- Disable linking on iOS and Android to avoid stripping required reflection metadata -->
	<Choose>
		<When Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">
			<PropertyGroup>
				<AndroidLinkMode Condition="'$(AndroidLinkMode)' == ''">None</AndroidLinkMode>
			</PropertyGroup>
		</When>
		<When Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">
			<PropertyGroup>
				<MTouchLink Condition="'$(MTouchLink)' == ''">None</MTouchLink>
			</PropertyGroup>
		</When>
	</Choose>

	<Target Name="_WarnAndroidLinkNotSetToNone" BeforeTargets="CoreCompile" Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android' and '$(AndroidLinkMode)' != 'None'">
		<Warning Code="UHR001" Text="Hot Reload won't work correctly when linker/trimming is enabled. Set AndroidLinkMode to 'None'." />
	</Target>
	
	<Target Name="_WarniOSLinkNotSetToNone" BeforeTargets="CoreCompile" Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios' and '$(MTouchLink)' != 'None'">
		<Warning Code="UHR001" Text="Hot Reload won't work correctly when linker/trimming is enabled. Set MTouchLink to 'None'." />
	</Target>

This fixes the issue for both CSharpMarkup and XAML, however this is still only without debugger attached (Created another issues to track that: https://github.com/unoplatform/uno.vscode/issues/1226)

dr1rrb avatar Dec 10 '25 17:12 dr1rrb

Hello @dr1rrb Just tested this, but I'm unable to get the HR working, heres a screenshot. I ran without debugging and I also update the csproj file. I am using the latest uno templates as at yesterday.

Image

saent-x avatar Dec 10 '25 17:12 saent-x

Hum this is yet another issue 🫤 : looks like your application is not able to initialize Hot-Reload while it was working in your first message. (BTW I noticed that the error message might wrongly report details about debugger being attached or not, updating that right now).

Are you able to send me the content of the Uno Platform - Hot Reload output window?

Also you are mentioning that "I am using the latest uno templates as at yesterday.", did you mean "Uno.Sdk" (you can find it in the global.json file at the root of your workspace) , and if so, did you reloaded you VSCode window ? Finally could you please try to update the latest dev version, i.e. 6.5.0-dev.67 (don't forget to reload VSCode window)?

dr1rrb avatar Dec 10 '25 22:12 dr1rrb

Hey @saent-x just found an issue with rider which might explain why your dev server is not connecting back : https://github.com/unoplatform/uno/issues/22013#issuecomment-3647327935

dr1rrb avatar Dec 12 '25 16:12 dr1rrb