ReactiveUI: Xamarin.iOS Linker break RxApp.

Using Xamarin.iOS.

When building in Release | Ad Hoc | App Store for the device the Linker comes in and seems to remove necessary methods in RxApp. Setting “Don’t link” option when building resolve the issue but it would be great if the Linker could do his job correctly. A hint is to mark “hard-to-discover” methods using the [Preserve] attribute.

Unfortunately I can’t easily figure out which methods are “hard-to-discover”.

Here is a stack trace when building starter-mobile in Release for the device :

System.TypeInitializationException: An exception was thrown by the type initializer for ReactiveUI.RxApp ---> System.Exception: Object reference not set to an instance of an object
  at ReactiveUI.DependencyResolverMixins.GetService[ILogger] (IDependencyResolver This, System.String contract) [0x00000] in <filename unknown>:0
  at ReactiveUI.DefaultLogManager+<DefaultLogManager>c__AnonStorey5F.<>m__133 (System.Type type, System.Object _) [0x00000] in /Users/paul/github/native-dep-rebuild/deps/reactiveui/ReactiveUI/Logging-iOS.cs:83
  at ReactiveUI.MemoizingMRUCache`2[System.Type,ReactiveUI.IFullLogger].Get (System.Type key, System.Object context) [0x00000] in <filename unknown>:0
  at ReactiveUI.MemoizingMRUCache`2[System.Type,ReactiveUI.IFullLogger].Get (System.Type key) [0x00000] in <filename unknown>:0
  at ReactiveUI.DefaultLogManager.GetLogger (System.Type type) [0x0003c] in /Users/paul/github/native-dep-rebuild/deps/reactiveui/ReactiveUI/Logging-iOS.cs:99
  at ReactiveUI.LogHost.get_Default () [0x00034] in /Users/paul/github/native-dep-rebuild/deps/reactiveui/ReactiveUI/Logging-iOS.cs:173
  at ReactiveUI.RxApp..cctor () [0x00076] in /Users/paul/github/native-dep-rebuild/deps/reactiveui/ReactiveUI/RxApp.cs:75
  --- End of inner exception stack trace ---
  at CoEPOC.iOS.AppDelegate.SetupDependencyInjection (MonoTouch.Foundation.NSDictionary options) [0x00006] in /Users/nicolas/Developement/Apps/CoE POC/Mobile/CoEPOC-iOS/AppDelegate.cs:67
  at CoEPOC.iOS.AppDelegate.FinishedLaunching (MonoTouch.UIKit.UIApplication app, MonoTouch.Foundation.NSDictionary options) [0x00000] in /Users/nicolas/Developement/Apps/CoE POC/Mobile/CoEPOC-iOS/AppDelegate.cs:33
  at at (wrapper managed-to-native) MonoTouch.UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)
  at MonoTouch.UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x0004c] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIApplication.cs:38
  at CoEPOC.Application.Main (System.String[] args) [0x00000] in /Users/nicolas/Developement/Apps/CoE POC/Mobile/CoEPOC-iOS/Main.cs:23

About this issue

  • Original URL
  • State: closed
  • Created 11 years ago
  • Comments: 20 (6 by maintainers)

Most upvoted comments

Just create a class with a method and do not use it. Here is an example of what I do.

private static class LinkerFixer
{
    private static void KeepTheseStuff()
    {
        UITextField textField = null;
        textField.Placeholder = "";
    }
}

This prevents the linker from removing the Placholder setter from UITextField.

To identify which methods may be removed simply look where in your code you use BindTo.