Ошибка сборки Xamarin.Forms + Xamarin.ios Entityframework Core 2.1.1

Я работаю над приложением Xamarin.ios с Microsoft.EntityframeworkCore.Sqlite версии 2.1.1 с Xamarin.forms .NetStandard 2.0. Я не могу собрать приложение на iPhone, получаю следующую ошибку:

MTOUCH: ошибка MT3001: не удалось AOT сборки 'имя_проекта /iOS/obj/iPhone/Debug/device-builds/iphone10.2-11.0.2/mtouch-cache/Build/Microsoft.EntityFrameworkCore.dll' (MT3001) (имя_проекта.iOS)

Может ли кто-нибудь помочь мне разобраться с ошибкой, я попытался понизить версию entityframework до 2.0.0, а также понизить версию Microsoft.extension.* До 2.0.0.

Поведение компоновщика: не связывать / связывать только SDK SDK Версия: 11.0

1 ответ

У меня была похожая ошибка при реализации EntityFrameworkCore в проекте, над которым я работаю. Решением для меня было добавить файл в мой проект iOS и получить это содержимое. Также я бегу Microsoft.EntityFrameworkCore.Sqlite версия 2.0.2 на данный момент без проблем.

<?xml version="1.0" encoding="utf-8" ?>
<linker>
    <!-- LinkDescription.xml. File added to iOS project by @cwrea for adaptation to EF Core.

    Prevents runtime errors when reflection is used for certain types that are not otherwise referenced
    directly in the project, and that would be removed by the Xamarin linker.

    These kinds of runtime errors do occur in particular when using Entity Framework Core on iOS. EF Core's
    query parser does reference certain .NET methods _only_ via reflection, and it is those reflection-only
    instances that we need to guard against by ensuring the linker includes them. For the curious, search
    for mentions of "GetRuntimeMethod" at https://github.com/aspnet/EntityFramework. Use of EF Core more
    advanced than this sample may require additional types/methods added to those below.

    Include the following in the project build settings under "Additional mtouch arguments":
      [hyphen][hyphen]xml=${ProjectDir}/LinkDescription.xml

    There is supposed to be a "LinkDescription" build action for this linker config file so the step above
    shouldn't be necessary, but at time of writing Visual Studio 2017 for PC doesn't show that build action
    in iOS projects, even though it is an option within iOS projects on Visual Studio 2017 for Mac.
    -->
    <assembly fullname="mscorlib">
        <type fullname="System.String">
            <method name="Compare"></method>
            <method name="CompareTo"></method>
            <method name="ToUpper"></method>
            <method name="ToLower"></method>
        </type>
    </assembly>
    <assembly fullname="System.Core">
        <type fullname="System.Linq.Expressions.Expression`1"></type>
        <type fullname="System.Linq.Queryable"></type>
    </assembly>
</linker>

Вам также нужно будет установить эти файлы Build Action Ссылка Description. Кроме того, вам не нужно копировать этот файл в выходной каталог. Он используется только во время сборки.

В настройках вашего проекта для iOS проект, вам нужно будет поместить --xml=${ProjectDir}/LinkDescription.xml в Additional mtouch arguments раздел в iOS Build,

Надеюсь это поможет!