ryancheung/FreeTypeSharp

Support for net 6.0 + apple m1

Closed this issue · 2 comments

Hi.

There is a problem with apps built with net 6.0 sdk.
Because net 6.0 has native M1 support, and could run without rosetta, when libfreetype.dylib got loaded, app crashes because dylib is x86_64, but .net runtime is arm64.
I've fixed it on my side by rebuilding freetype from sources. But it would be nice if you make native dylib available in your nuget package.

I used this commands for building freetype on osx:

cd /path/to/freetype/src/dir/wtih/CMakeLists.txt
cmake -B build -D BUILD_SHARED_LIBS=true -D CMAKE_BUILD_TYPE=Release -D CMAKE_OSX_ARCHITECTURES=arm64\;x86_64
cd build
make -j 4

It should produce universal macos dylib, which should run on both x86_64 and arm processors.

To verify that your dylib is universal type in terminal file libfreetype.dylib and there should be something like this:

me@my-mac build % file libfreetype.6.18.0.dylib 
libfreetype.6.18.0.dylib: Mach-O universal binary with 2 architectures: [x86_64:Mach-O 64-bit dynamically linked shared library x86_64] [arm64:Mach-O 64-bit dynamically linked shared library arm64]
libfreetype.6.18.0.dylib (for architecture x86_64):	Mach-O 64-bit dynamically linked shared library x86_64
libfreetype.6.18.0.dylib (for architecture arm64):	Mach-O 64-bit dynamically linked shared library arm64

Thanks! I'll update freetype to latest version and add apple M1 native lib.

The latest nuget pacakge 2.0.0.3-ci should include this fix now.