The same code worked on iOS, but failed on MacOS, no meaningful log to support me debugging this (newbie to Apple development)
When I unchecked this "Edit > Canvas > Automatically Refresh Canvas", mac worked.
Hopefully it will be fixed in future XCode versions.
Thanks for the post.
BTW: The Canvas options sometimes disappears for no reason, and when I close XCode, this option is turned ON by default for some reason.