avalonia-dotnet-templates icon indicating copy to clipboard operation
avalonia-dotnet-templates copied to clipboard

iOS build fails on Mac M1 with VS2022 using avalonia.xplat template

Open rolandh15 opened this issue 2 years ago • 8 comments

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:

  1. Ensure dotnet core SDK 6.0.300 is installed
  2. Ensure the latest version of XCode is installed
  3. Create an empty directory
  4. Run dotnet new avalonia.xplat
  5. run dotnet workload restore
  6. run dotnet restore
  7. cd {myproject}.iOS
  8. dotnet run
  9. 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.

rolandh15 avatar May 30 '22 10:05 rolandh15

Please, try 6.0.202 sdk version. I wonder if they had breaking changes again.

maxkatz6 avatar May 30 '22 13:05 maxkatz6

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.

rolandh15 avatar Jun 05 '22 09:06 rolandh15

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?

rolandh15 avatar Jun 05 '22 09:06 rolandh15

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).

maxkatz6 avatar Jun 16 '22 00:06 maxkatz6

Works as expected with the new version.

rolandh15 avatar Jun 23 '22 00:06 rolandh15

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?

rolandh15 avatar Jun 23 '22 00:06 rolandh15

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 avatar Jun 23 '22 09:06 NullFragment

@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.

maxkatz6 avatar Jun 23 '22 14:06 maxkatz6