avalonia-dotnet-templates
avalonia-dotnet-templates copied to clipboard
iOS build fails on Mac M1 with VS2022 using avalonia.xplat template
Describe the bug
Using a brand new project created from the Avalonia xplat
template, on MacOS Monterey, it is not possible to build the iOS project.
To Reproduce
Steps to reproduce the behavior:
- Ensure dotnet core SDK 6.0.300 is installed
- Ensure the latest version of XCode is installed
- Create an empty directory
- Run
dotnet new avalonia.xplat
- run
dotnet workload restore
- run
dotnet restore
-
cd {myproject}.iOS
-
dotnet run
- See error:
error CS0012: The type 'UIResponder' is defined in an assembly that is not referenced. You must add a reference to assembly 'Xamarin.iOS, Version=0.0.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065'.
Expected behavior I should be able to build the iOS application and launch it on the Simulator like the Avalonia Wordle application.
Desktop (please complete the following information):
- OS: MacOS
- Version Monterey
Additional context Could not isolate the difference between the Wordle application and the created application from the template. The Avalonia Wordle sample application compiles and launches, but crashes on Startup. Would appreciate a workaround until the next stable version is published if this can be solved.
Please, try 6.0.202 sdk version. I wonder if they had breaking changes again.
I tried with 6.0.200 and was unable to build on macOS, but WebAssembly and Desktop, and Android worked. I will change to 6.202 and retry.
Still does not work, same error occurs as before:
The type 'UIResponder' is defined in an assembly that is not referenced.
with SDK 6.0.202. Is there a specific version of XCode required as well? or will the latest be sufficient?
I was able to reproduce. Yes, it's caused by breaking changes in .NET 6 minor versions.
This template targets Avalonia nightly version that was built with older version of .NET SDK and Xamarin.iOS. I it was fixed after I changed Avalonia version to a newer nighthly build - 0.10.999-cibuild0021189-beta Works with both 6.0.202 and 6.0.301 sdk (changing global.json version to a specific one).
Works as expected with the new version.
Leaving the issue open because the template should probably be upgraded or at least somewhat keep its targeting up to date with the CI builds. I wonder if there is not a way to install a CI built template from dotnet instead of the default one?
I came across this issue while trying to look into Avalonia. Upgrading to a newer nightly build still results in build failures for me (nothing was modified in the project other than the NuGet package versions):
XamlX.XamlParseException: Unable to resolve type FluentTheme from namespace https://github.com/avaloniaui Line 10, position 10.
MainWindow.axaml.cs(9, 13): [CS0103] The name 'InitializeComponent' does not exist in the current context
MainView.axaml.cs(9, 13): [CS0103] The name 'InitializeComponent' does not exist in the current context
I'm using Avalonia Templates @ v0.10.14
and I've tried all of the Avalonia NuGet packages at 0.10.999-cibuild0021189-beta
and 0.10.999-cibuild0021319-beta
@NullFragment not related. Check breaking changes page https://github.com/AvaloniaUI/Avalonia/wiki/Breaking-Changes Note that 11.0 is in development and nightly builds might not be stable.