Xamarin Linker stipping out static class properties?

800 Views Asked by At

In VS 2013, Xamarin Forms.

Our Android & IOS app has a static class:

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

This class is stripped by the linker in the iOS device debug build, but not in the simulator or Android.

See attached screenshot.

I have set the Debug Linker for iPhone to Do Not Link, yet this static class is removed.

??????

enter image description here

2

There are 2 best solutions below

0
On BEST ANSWER

You can set a preserve attribute to your class: http://developer.xamarin.com/guides/ios/advanced_topics/linker/ See the section: Preserving Code

Example:

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

    public class PreserveAttribute : Attribute
    {
    }
0
On

I also found that I had to check the "Enable generic value type sharing" in the Advanced tab of "iOS Build"