Skiasharp: Xamarin 4.0 , FFImageLoading and SkiaSharp

Created on 31 May 2019  路  13Comments  路  Source: mono/SkiaSharp

Hi People.

I am updating my project to Xamarin 4.0, and I am using FFImageLoading with skiaSharp, but with skiaSharp 1.68.0 I have this problem.

/Users/LALA/Projects/Clarika/Imperial-ClienteFiel/ClienteFiel.Forms.iOS/MTOUCH: Error MT0009: Error while loading assemblies: /Users/hugo/.nuget/packages/skiasharp/1.68.0/runtimes/win-x86/native/libSkiaSharp.dll (MT0009) (ClienteFiel.Forms.iOS)

My question.

Do support SkiaSharp the new version o Xamarin?

Thx!

Most helpful comment

Any more info on this issue? I have the same problem. Can not make an iOS build with SkiaSharp 1.68.0.

All 13 comments

I'm having the same issue. Xamarin Forms 4.0.0, Visual Studio 2019 for Windows, SkiaSharp.Views.Forms 1.68.0. The workaround of # 5265 to switch from x64 to Any CPU temporally resolve the issue.

I am having the same issue.

How would I change to Any CPU on VS for Mac?

Any more info on this issue? I have the same problem. Can not make an iOS build with SkiaSharp 1.68.0.

Any news on this issue ?

I'm struggeling with this issue as well. As soon as I upgrade to 1.68.0 it cannot load the assemblie. I've tried many suggestions, none solved the problem so far.

I am facing the same issue with Xamarin Forms 4.2.0.848062 and SkiaSharp 1.68.0
Error Details : MTOUCH : error MT0009: Error while loading assemblies:

Is there any fix provided for this issue

If you are still hitting this issue, it is likely due to a configuration on your csproj file for your iOS project that looks similar to the following.

<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|iPhone' ">
    <DebugType>none</DebugType>
    <Optimize>true</Optimize>
    <OutputPath>bin\iPhone\Release</OutputPath>
    <DefineConstants>__IOS__;__MOBILE__;__UNIFIED__;Release;</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
    <MtouchArch>ARM64</MtouchArch>
    <CodesignKey>iPhone Distribution</CodesignKey>
    <MtouchUseLlvm>true</MtouchUseLlvm>
    <MtouchFloat32>true</MtouchFloat32>
    <MtouchEnableSGenConc>true</MtouchEnableSGenConc>
    <MtouchLink>SdkOnly</MtouchLink>
    <MtouchHttpClientHandler>NSUrlSessionHandler</MtouchHttpClientHandler>
    <PlatformTarget>x86</PlatformTarget>
</PropertyGroup>

Remove the <PlatformTarget>x86</PlatformTarget> and you should be good to to go. Make sure that you do this for all of your iPhone release configurations, likely Release, Ad-Hoc and AppStore.

If you are still hitting this issue, it is likely due to a configuration on your csproj file for your iOS project that looks similar to the following.

<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|iPhone' ">
    <DebugType>none</DebugType>
    <Optimize>true</Optimize>
    <OutputPath>bin\iPhone\Release</OutputPath>
    <DefineConstants>__IOS__;__MOBILE__;__UNIFIED__;Release;</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
    <MtouchArch>ARM64</MtouchArch>
    <CodesignKey>iPhone Distribution</CodesignKey>
    <MtouchUseLlvm>true</MtouchUseLlvm>
    <MtouchFloat32>true</MtouchFloat32>
    <MtouchEnableSGenConc>true</MtouchEnableSGenConc>
    <MtouchLink>SdkOnly</MtouchLink>
    <MtouchHttpClientHandler>NSUrlSessionHandler</MtouchHttpClientHandler>
    <PlatformTarget>x86</PlatformTarget>
</PropertyGroup>

Remove the <PlatformTarget>x86</PlatformTarget> and you should be good to to go. Make sure that you do this for all of your iPhone release configurations, likely Release, Ad-Hoc and AppStore.

Thanks! Works for me!

I don't have that platform target line and still hitting this error

I can build locally, because I do not have the PlatformTarget line, but I cannot build via App Center. It's pulling the win-64 version of SkiaSharp:

/Users/runner/work/1/s/iOS/myProject.iOS.csproj" (Rebuild target) (1) ->
(_CompileToNative target) ->
MTOUCH : error MT0009: Error while loading assemblies: /Users/runner/.nuget/packages/skiasharp/2.80.1/runtimes/win-x64/native/libSkiaSharp.dll [/Users/runner/work/1/s/iOS/myProject.iOS.csproj]

0 Warning(s)
1 Error(s)

Time Elapsed 00:05:49.82

[error]Xamarin.iOS task failed with error Error: /Library/Frameworks/Mono.framework/Versions/6_8_1/bin/msbuild failed with return code: 1. For guidance on setting up the build definition, see https://go.microsoft.com/fwlink/?LinkId=760847.

The link is about building apps with AppCenter. This was working great until I needed SkiaSharp for something and had to add it.

I saw you posed here too: https://github.com/xamarin/xamarin-macios/issues/5265

I'll see what I can do, but maybe you can try adding ExcludeAssets="runtimes":

<PackageReference Include="SkiaSharp" Version="2.80.1" ExcludeAssets="runtimes" />

This should _force_ the files to not even be loaded.

But, could you try out the v2.80.2 preview, that _might_ fix it.

Also, make sure you add it to the final app project as well.

Hello,

I'm having the same problem here after updating SkiaSharp from 1.60.3 to 2.80.2
Solution is Xamarin.Forms (shared) and an iOS project and Android project. Android works just fine.

Here's the error in iOS build:
Severity Code Description Project File Line Suppression State
Error Error while loading assemblies: /Users/[user]/Library/Caches/Xamarin/mtbs/builds/[mycompany].iOS/2b8bb42efaa82e056d0923743e8a2829/bin/iPhoneSimulator/Debug/libSkiaSharp.dll. [mycompany].iOS

2> /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/bin/mtouch @/Users/[user]/Library/Caches/Xamarin/mtbs/builds/[mycompany].iOS/2b8bb42efaa82e056d0923743e8a2829/obj/iPhoneSimulator/Debug/response-file.rsp "--gcc_flags=-Xlinker -sectcreate -Xlinker __TEXT -Xlinker __entitlements -Xlinker /Users/[user]/Library/Caches/Xamarin/mtbs/builds/[mycompany].iOS/2b8bb42efaa82e056d0923743e8a2829/obj/iPhoneSimulator/Debug/Entitlements.xcent"
2>C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Xamarin\iOS\Xamarin.iOS.Common.targets(885,3): error MT0009: Error while loading assemblies: /Users/[user]/Library/Caches/Xamarin/mtbs/builds/[mycompany].iOS/2b8bb42efaa82e056d0923743e8a2829/bin/iPhoneSimulator/Debug/libSkiaSharp.dll.

I have tried removin gthis from the iOS .proj file: <PlatformTarget>x86</PlatformTarget>

And I've tried adding this to the .proj file: ExcludeAssets="runtimes" in the skiaSharp reference(s).

If I regress to 1.60.3 it works just fine.

Any other potential fixes?

Thanks

Was this page helpful?
0 / 5 - 0 ratings