SkiaSharp icon indicating copy to clipboard operation
SkiaSharp copied to clipboard

[BUG] iOS - Method not found: SkiaSharp.SKTextBlob SkiaSharp.SKTextBlob.CreatePositioned

Open Martinn2 opened this issue 3 years ago • 8 comments

Description

Xamarin forms iOS app throws System.MissingMethodException when trying to call SKTextBlob.CreatePositioned. On android and windows it works fine

Code

SKTextBlob.CreatePositioned("aaaa",new SKFont(SKTypeface.CreateDefault()), new ReadOnlySpan<SKPoint>(new SKPoint[]{ SKPoint.Empty }) );

Basic Information

  • Version with issue: 2.88.0

  • Last known good version: -

  • IDE: Visual Studio 2022

  • Platform Target Frameworks:

    • iOS: the version of the iOS SDK you are compiling against - 15.5
  • Target Devices:

    • iPhone simulator iOS 15.5

Version info VS 2022 17.2.5 Xamarin.Forms 5.0.0.2196 Compiled on macOS Monterey version 12.4

To reproduce create new Xamarin.Forms app, install SkiaSharp 2.88.0 and use the code in "Code" section

Martinn2 avatar Jul 05 '22 19:07 Martinn2

I'm facing the same issue with 2.88.1

cschwarz avatar Aug 18 '22 17:08 cschwarz

Me too using 2.88.3. Is anyone looking into it?

JohnBot2013 avatar Nov 28 '22 13:11 JohnBot2013

Appears to be causing https://github.com/wieslawsoltes/Svg.Skia/issues/125

charlesroddie avatar Dec 01 '22 11:12 charlesroddie

To whomever hits this, we encountered this issue on Uno Platform and the root cause of this is the fact that SkiaSharp in .NET Standard 2.0 references System.Memory in a different version and that version mismatch causes issues with ReadOnlySpan. The workaround is to add the following targets to the iOS .csproj:

<Target Name="VSMac_RemoveSystemMemory" BeforeTargets="ResolveAssemblyReferences">
  <ItemGroup>
    <_ReferenceToRemove Include="@(Reference)" Condition="'%(Reference.Identity)'=='System.Memory'" />
    <Reference Remove="@(_ReferenceToRemove)" />
    <Reference Include="System.Memory" />
  </ItemGroup>
</Target>

<Target Name="VS_RemoveSystemMemory" BeforeTargets="FindReferenceAssembliesForReferences">
  <ItemGroup>
    <_ReferencePathToRemove Include="@(ReferencePath)" Condition="'%(ReferencePath.NuGetPackageId)'=='System.Memory'" />
    <ReferencePath Remove="@(_ReferencePathToRemove)" />
  </ItemGroup>
</Target>

MartinZikmund avatar Feb 09 '23 18:02 MartinZikmund

To whomever hits this, we encountered this issue on Uno Platform and the root cause of this is the fact that SkiaSharp in .NET Standard 2.0 references System.Memory in a different version and that version mismatch causes issues with ReadOnlySpan. The workaround is to add the following targets to the iOS .csproj:

<Target Name="VSMac_RemoveSystemMemory" BeforeTargets="ResolveAssemblyReferences">
  <ItemGroup>
    <_ReferenceToRemove Include="@(Reference)" Condition="'%(Reference.Identity)'=='System.Memory'" />
    <Reference Remove="@(_ReferenceToRemove)" />
    <Reference Include="System.Memory" />
  </ItemGroup>
</Target>

<Target Name="VS_RemoveSystemMemory" BeforeTargets="FindReferenceAssembliesForReferences">
  <ItemGroup>
    <_ReferencePathToRemove Include="@(ReferencePath)" Condition="'%(ReferencePath.NuGetPackageId)'=='System.Memory'" />
    <ReferencePath Remove="@(_ReferencePathToRemove)" />
  </ItemGroup>
</Target>

This really worked for me. Thank you very much. Xamarin.Forms = 5.0.0.2545 SkiaSharp.Views.Forms = 2.88.3 Svg.Skia = 0.5.18

fabiansanchez18 avatar Feb 13 '23 16:02 fabiansanchez18

To whomever hits this, we encountered this issue on Uno Platform and the root cause of this is the fact that SkiaSharp in .NET Standard 2.0 references System.Memory in a different version and that version mismatch causes issues with ReadOnlySpan. The workaround is to add the following targets to the iOS .csproj:

<Target Name="VSMac_RemoveSystemMemory" BeforeTargets="ResolveAssemblyReferences">
  <ItemGroup>
    <_ReferenceToRemove Include="@(Reference)" Condition="'%(Reference.Identity)'=='System.Memory'" />
    <Reference Remove="@(_ReferenceToRemove)" />
    <Reference Include="System.Memory" />
  </ItemGroup>
</Target>

<Target Name="VS_RemoveSystemMemory" BeforeTargets="FindReferenceAssembliesForReferences">
  <ItemGroup>
    <_ReferencePathToRemove Include="@(ReferencePath)" Condition="'%(ReferencePath.NuGetPackageId)'=='System.Memory'" />
    <ReferencePath Remove="@(_ReferencePathToRemove)" />
  </ItemGroup>
</Target>

Thank you Martin. This worked for me too.

JohnBot2013 avatar Feb 14 '23 11:02 JohnBot2013

To whomever hits this, we encountered this issue on Uno Platform and the root cause of this is the fact that SkiaSharp in .NET Standard 2.0 references System.Memory in a different version and that version mismatch causes issues with ReadOnlySpan. The workaround is to add the following targets to the iOS .csproj:

<Target Name="VSMac_RemoveSystemMemory" BeforeTargets="ResolveAssemblyReferences">
  <ItemGroup>
    <_ReferenceToRemove Include="@(Reference)" Condition="'%(Reference.Identity)'=='System.Memory'" />
    <Reference Remove="@(_ReferenceToRemove)" />
    <Reference Include="System.Memory" />
  </ItemGroup>
</Target>

<Target Name="VS_RemoveSystemMemory" BeforeTargets="FindReferenceAssembliesForReferences">
  <ItemGroup>
    <_ReferencePathToRemove Include="@(ReferencePath)" Condition="'%(ReferencePath.NuGetPackageId)'=='System.Memory'" />
    <ReferencePath Remove="@(_ReferencePathToRemove)" />
  </ItemGroup>
</Target>

Works like a charm, thanks!

jl-mobitech avatar Mar 07 '23 16:03 jl-mobitech

Hi I have this error on UWP build from Unity, could it be linked ? How to adapt the IOS fix if it is ?

1>EXEC : error : Unity.IL2CPP.Building.BuilderFailedException: Svg.Skia.cpp
1>C:\DevPerso\_Builds\HarborHL\Il2CppOutputProject\Source\il2cppOutput\Svg.Skia.cpp(11638): error C2664: 'SKTextBlob_t5A224EAAE51CDAE3AC22F0117DB16B3D16BDE3DB *SKTextBlob_CreatePositioned_mD6854C5848231F736785A7E922DBC41145BB8C69(String_t *,SKFont_tC395A6D2120F06176FC8D28A21BD2B70511A9D0E *,ReadOnlySpan_1_t6EC0A6555D2AA6759727FFA6D6B26499FE81A6BF,const RuntimeMethod *)'�: impossible de convertir l'argument 3 de 'ReadOnlySpan_1_t72A99341F6FD442048F249ECC03200102D1EA4AF' en 'ReadOnlySpan_1_t6EC0A6555D2AA6759727FFA6D6B26499FE81A6BF'
1>C:\DevPerso\_Builds\HarborHL\Il2CppOutputProject\Source\il2cppOutput\Svg.Skia.cpp(11638): note: Aucun op�rateur de conversion d�finie par l'utilisateur disponible qui puisse effectuer cette conversion, ou l'op�rateur ne peut pas �tre appel�
1>C:\DevPerso\_Builds\HarborHL\Il2CppOutputProject\Source\il2cppOutput\Svg.Skia.cpp(4493): note: voir la d�claration de 'SKTextBlob_CreatePositioned_mD6854C5848231F736785A7E922DBC41145BB8C69'
1>C:\DevPerso\_Builds\HarborHL\Il2CppOutputProject\Source\il2cppOutput\Svg.Skia.cpp(11638): note: lors de la tentative de mise en correspondance de la liste des arguments '(String_t *, SKFont_tC395A6D2120F06176FC8D28A21BD2B70511A9D0E *, ReadOnlySpan_1_t72A99341F6FD442048F249ECC03200102D1EA4AF, int)'
1>
1>Invocation was: Executable: "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.37.32822\bin\HostX64\ARM64\cl.exe"
1>Arguments: "C:\DevPerso\_Builds\HarborHL\Il2CppOutputProject\Source\il2cppOutput\Svg.Skia.cpp" /nologo /c /bigobj /W3 /Z7 /EHs /GR- /Gy /utf-8 /wd4102 /wd4800 /wd4056 /wd4190 /wd4723 /wd4467 /wd4503 /wd4996 /wd4200 /wd4834 /wd4722 /Ox /Oi /Oy- /GS- /Gw /GF /Zo /Yupch-cpp.hpp /Fp"C:\DevPerso\_Builds\HarborHL\build\obj\il2cppOutputProject\ARM64\Release\57DA57A1CF804A4DFC88B3636B712447.pch" /MD -d2ssa-cfg-jt- /DWINDOWS_UWP /DUNITY_UWP /DUNITY_WSA_10_0 /DUNITY_WSA /DUNITY_WINRT /DPLATFORM_WINRT /DNET_4_0 /DUNITY_AOT /DIL2CPP_MONO_DEBUGGER_DISABLED /DGC_NOT_DLL /DRUNTIME_IL2CPP /DBASELIB_INLINE_NAMESPACE=il2cpp_baselib /DIL2CPP_DEFAULT_DATA_DIR_PATH=Data/il2cpp_data /DBASELIB_USE_DYNAMICLIBRARY=1 /D_WIN32 /DWIN32 /DWIN32_THREADS /D_WINDOWS /DWINDOWS /D_UNICODE /DUNICODE /D_CRT_SECURE_NO_WARNINGS /D_SCL_SECURE_NO_WARNINGS /D_WINSOCK_DEPRECATED_NO_WARNINGS /DNOMINMAX /D_NDEBUG /DNDEBUG /DWINDOWS_SDK_BUILD_VERSION=22621 /D__WRL_NO_DEFAULT_LIB__ /DWINAPI_FAMILY=WINAPI_FAMILY_APP /I"C:\DevPerso\_Builds\HarborHL\Il2CppOutputProject\IL2CPP\libil2cpp" /I"C:\DevPerso\_Builds\HarborHL\Il2CppOutputProject\IL2CPP\libil2cpp" /I"C:\DevPerso\_Builds\HarborHL\Il2CppOutputProject\IL2CPP\external\bdwgc\include" /I"C:\DevPerso\_Builds\HarborHL\Il2CppOutputProject\IL2CPP\external\xxHash" /I"C:\DevPerso\_Builds\HarborHL\Il2CppOutputProject\IL2CPP\external\baselib\Include" /I"C:\DevPerso\_Builds\HarborHL\Il2CppOutputProject\IL2CPP\external\baselib\Platforms\UniversalWindows\Include" /I"C:\DevPerso\_Builds\HarborHL\Il2CppOutputProject\IL2CPP\libil2cpp\pch" /I"C:\DevPerso\_Builds\HarborHL\Il2CppOutputProject\IL2CPP\libil2cpp\os\ClassLibraryPAL\brotli\include" /I"C:\DevPerso\_Builds\HarborHL\Il2CppOutputProject\Source" /I"C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.37.32822\include" /I"C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\shared" /I"C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um" /I"C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\winrt" /I"C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\ucrt" /Fo"C:\DevPerso\_Builds\HarborHL\build\obj\il2cppOutputProject\ARM64\Release\7CE9CD23BEFFDE1F4F02B0DE971C7609.obj" /Fd"C:\DevPerso\_Builds\HarborHL\build\obj\il2cppOutputProject\ARM64\Release\7CE9CD23BEFFDE1F4F02B0DE971C7609.pdb"
1>EnvArg key: PATH value: C:\Program Files (x86)\Windows Kits\10\bin\10.0.22621.0\x64;C:\Program Files (x86)\Windows Kits\10\bin\x64;C:\Program Files (x86)\Windows Kits\10\bin\10.0.22621.0\x86;C:\Program Files (x86)\Windows Kits\10\bin\x86;C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.37.32822\bin\HostX64\x64
1>
1>   at Unity.IL2CPP.Building.CppProgramBuilder.BuildAllCppFiles(IEnumerable`1 sourceFilesToCompile, IBuildStatisticsCollector statisticsCollector)

SashelI avatar Jan 22 '24 13:01 SashelI