question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Bug] .NET MAUI projects do not build on Apple M1

See original GitHub issue

Description

dotnet new maui then dotnet build fails on my M1 with:

Unhandled exception. System.TypeInitializationException: The type initializer for 'SkiaSharp.SKObject' threw an exception.
 ---> System.DllNotFoundException: Unable to load library 'libSkiaSharp'.

If I check some of the native libraries, they are missing arm64 architectures, such as libSkiaSharp.dylib:

file /usr/local/share/dotnet/packs/Microsoft.Maui.Resizetizer.Sdk/6.0.100-preview.6.1003+sha.5c159aabf-azdo.4977641/targets/libSkiaSharp.dylib 
/usr/local/share/dotnet/packs/Microsoft.Maui.Resizetizer.Sdk/6.0.100-preview.6.1003+sha.5c159aabf-azdo.4977641/targets/libSkiaSharp.dylib: Mach-O universal binary with 1 architecture: [x86_64:Mach-O 64-bit dynamically linked shared library x86_64]
/usr/local/share/dotnet/packs/Microsoft.Maui.Resizetizer.Sdk/6.0.100-preview.6.1003+sha.5c159aabf-azdo.4977641/targets/libSkiaSharp.dylib (for architecture x86_64):	Mach-O 64-bit dynamically linked shared library x86_64

Then also libHarfBuzzSharp.dylib:

file /usr/local/share/dotnet/packs/Microsoft.Maui.Resizetizer.Sdk/6.0.100-preview.6.1003+sha.5c159aabf-azdo.4977641/targets/libHarfBuzzSharp.dylib
/usr/local/share/dotnet/packs/Microsoft.Maui.Resizetizer.Sdk/6.0.100-preview.6.1003+sha.5c159aabf-azdo.4977641/targets/libHarfBuzzSharp.dylib: Mach-O universal binary with 1 architecture: [x86_64:Mach-O 64-bit dynamically linked shared library x86_64]
/usr/local/share/dotnet/packs/Microsoft.Maui.Resizetizer.Sdk/6.0.100-preview.6.1003+sha.5c159aabf-azdo.4977641/targets/libHarfBuzzSharp.dylib (for architecture x86_64):	Mach-O 64-bit dynamically linked shared library x86_64

What we’re doing in xamarin-android is merging several architectures into a single .dylib:

https://github.com/xamarin/xamarin-android/blob/71ae5566888487d73c9ef99b01189819074cb071/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Build.Tasks.targets#L382-L385

Expected Behavior

I can build .NET MAUI apps on an Apple M1.

Actual Behavior

Some native libraries are missing arm64 architectures.

Basic Information

dotnet --version
6.0.100-preview.6.21355.2

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
mattleibowcommented, Aug 18, 2021

For the resizetizer stuff, I just need to bump SkiaSharp. 2.88 has arm64 support

0reactions
jonathanpepperscommented, Aug 17, 2021

As far as no m1 support is their some staffers are using m1s

Not sure what is being asked here?

I have an M1. My first goal was to get the Android workload working, because I’m on the Xamarin.Android team

Read more comments on GitHub >

github_iconTop Results From Across the Web

BUILD Error NETSDK1147 on Apple M1 · Issue #101
Hello I get the following errors with this command dotnet build HelloMaui -t:Run -f net6.0-ios. Error:
Read more >
Net Maui cant compile a fresh macos project
MAUI is not offical support for macOS yet as verion of 17.3 Visual studio. the most important is Pre-requisites your mac have to...
Read more >
MAUI on Mac - Visual Studio 2022 17.4.2 : r/dotnetMAUI
I verified that this is not specific to my project by creating a new MAUI project on the Mac using the template and...
Read more >
MAUI App launches fine in iOS Simulator, refuses to build ...
When I start building a default MAUI project for a physical iOS device on Visual Studio for Mac Preview 17.3 (build 191) on...
Read more >
Setting up your Mac for .NET MAUI in 2023 | by Saurav Sahu
Go to the App Store and download the latest version of XCode. You DON'T need an Apple Developer Account. To run your app...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found