Xamarin iOS链接器问题 [英] Xamarin iOS Linker Issue

查看:85
本文介绍了Xamarin iOS链接器问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个具有共享代码的android和ios项目的应用程序。 android应用程序运行完美,并使用仅SDK链接程序。我还有一个链接器文件,用于强制链接器不删除使用的功能-这是一个相当大的文件,并且我还尝试添加了一系列保留属性。但是,在iOS项目中,情况相同,无法执行相同的操作。它将从EF中删除某些内容并引发此异常:

I have an application that has an android and ios project with shared code. The android application works perfect and uses the SDK Only linker. I also have a Linker file to enforce linker not removing used functions - Which is a fairly large file and I've also tried adding a bunch of preserve attributes. Same situation in the iOS project however, doing the same thing doesn't work. It removes something from EF and throws this exception:

"The type initializer for 'Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions' threw an exception. ---> System.InvalidOperationException"

整个代码库无需链接即可正常工作。我添加了许多mtouch参数来尝试跳过它,但是它们也不起作用。

This whole code base works perfectly fine without the linking. I've added a bunch of mtouch arguments to try and skip it but that ain't working either.

--linkskip=Microsoft.EntityFrameworkCore 
--linkskip=Microsoft.EntityFrameworkCore.Design 
--linkskip=Microsoft.EntityFrameworkCore.Sqlite 
--linkskip=Microsoft.EntityFrameworkCore.Tools 
--linkskip=Interactive.Async 
--linkskip=Remotion.Linq 
--linkskip=System.Data 
--linkskip=System.Collections.Immutable 
--linkskip=System.Diagnostics.DiagnosticSource 
--linkskip=Microsoft.Extensions.Logging 
--linkskip=System.Interactive.Async 
--linkskip=Microsoft.EntityFrameworkCore.Abstractions 
--linkskip=Microsoft.Extensions.DependencyInjection 
--linkskip=Microsoft.Extensions.Caching.Memory 
--linkskip=System.ComponentModel.Annotations

我将在NuGet存储库中添加每个DLL,这将使链接程序无用。这是iOS链接器的错误还是我在这里遗漏了什么?我已经阅读了文档[ https: //docs.microsoft.com/zh-cn/xamarin/ios/deploy-test/linker?tabs=windows] ,并在互联网上到处搜索,但没有发现任何问题。感谢您的帮助。

I'm about to add every DLL in NuGet repository which will make the Linker useless. Is this a bug for the iOS Linker or what am I missing here? I've read the documentation [https://docs.microsoft.com/en-us/xamarin/ios/deploy-test/linker?tabs=windows] and searched everywhere on the internet and nothing comes up. Any help is appreciated.

谢谢

推荐答案

如果在iOS项目上使用仅链接SDK程序集选项,那么所有这些-linkskip 参数都不会执行任何操作,因为仅链接了SDK程序集。因此 EntityFrameworkCore 可能正在使用Xamarin.iOS SDK程序集中的链接链接掉的东西。 System.Linq 是SDK的一部分,并为许多数据库类型添加了扩展方法。

If you are using "Link SDK assemblies only" option on iOS project, then all of those --linkskip arguments won't do anything as only the SDK assemblies are being linked. So the EntityFrameworkCore might be using something that is being linked away that is in the Xamarin.iOS SDK assemblies. System.Linq is part of the SDK and adds extension methods for many database types.

所以我认为您可能会遇到此问题: https://github.com/xamarin/xamarin-macios/issues / 3394

So I think you may be hitting this issue: https://github.com/xamarin/xamarin-macios/issues/3394

如果是这样,请尝试放入:

If so, try putting:

[assembly: Preserve (typeof (System.Linq.Queryable), AllMembers = true)]

命名空间之外的iOS项目的Main.cs文件,例如:

in the Main.cs file of the iOS project outside of the namespace, e.g.:

using UIKit;

[assembly: Preserve (typeof (System.Linq.Queryable), AllMembers = true)]
namespace
{
    ...
}

这篇关于Xamarin iOS链接器问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆