【问题标题】:Xamarin Linker stipping out static class properties?Xamarin Linker 删除静态类属性?
【发布时间】:2014-12-29 21:36:24
【问题描述】:

在 VS 2013 中,Xamarin 表单。

我们的 Android 和 IOS 应用有一个静态类:

public static class CacheKeys
{
    public static string RememberMeEmail = "RememberMeEmail";
    public static string RememberMeSwitch = "RememberMeSwitch";
}

这个类在 iOS 设备调试版本中被链接器剥离,但在 模拟器或安卓。

见附件截图。

我已将 iPhone 的调试链接器设置为不链接,但这个静态类是 删除。

??????

【问题讨论】:

    标签: xamarin xamarin-linker


    【解决方案1】:

    您可以为您的班级设置一个保留属性:http://developer.xamarin.com/guides/ios/advanced_topics/linker/ 请参阅部分:保留代码

    例子:

    [Preserve]
        public static class LinkerPreserve
        {
            static LinkerPreserve()
            {
                throw new Exception(typeof(SQLitePersistentBlobCache).FullName);
            }
        }
    
        public class PreserveAttribute : Attribute
        {
        }
    

    【讨论】:

      【解决方案2】:

      我还发现我必须在“iOS Build”的“高级”选项卡中勾选“启用通用值类型共享”

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-06-11
        • 2011-07-29
        • 1970-01-01
        • 1970-01-01
        • 2014-09-10
        • 2011-01-29
        相关资源
        最近更新 更多