1

When creating a simple app with Monocross (using MonoTouch) and compiling for an iOS device I get some bad warnings, like this:

Warning MT4112: The registrar found a generic type: MonoCross.Touch.MXTouchViewController`1. Registering generic types with ObjectiveC is not supported, and will lead to random behavior and/or crashes. (MT4112).

I've read all I can find about using MonoTouch with generics on an iOS device and it's mostly not supported. My app currently works on an actual device, but the warnings worries me.

I guess my question is, what is the state of Monocross when you get these warnings even with the simplest of apps? Is it still not ready for professional use or are the warnings not relevant for the way generics is used in Monocross?

I can also add the following from Xamarin.iOS docs: "Xamarin.iOS does not currently support creating generic subclasses of the NSObject class"

Which is exactly what Monocross does, with for example the MXTouchTableViewController class.

patridge
  • 26,385
  • 18
  • 89
  • 135
Decept
  • 87
  • 5

1 Answers1

4

There is some history to this: creating generic subclasses of NSObject has never been a supported scenario, but unfortunately MonoTouch never enforced, nor warned about this fact. So people of course ended up doing exactly this.

Then one day I had to track down something that looked like a true heisenbug, and it turned out (after many hours of frustrating debugging) to be because the project in question was using generic subclasses of NSObject. The exact details are not important, but that's when the warning was added to MonoTouch.

My point here is people have been using generic subclasses of NSObject for a long time, without running into any problems. If you test your app extensively (which you should do anyway), don't worry about this.

But if you do run into strange and inexplicable behavior, we'll most likely ask you to fix these warnings before looking into any claims that you've found a bug in MonoTouch.

Rolf Bjarne Kvinge
  • 19,253
  • 2
  • 42
  • 86
  • Has the warning been changed back to an exception in Xamarin.Monotouch 6.3.2? I'm getting a `{MonoTouch.MonoTouchException: The registrar found an invalid type Cirrious.MvvmCross.Dialog.Touch.MvxTouchDialogViewController 1[[Core.AlertVM, ViewModelsiOS, Version=1.0.4842.16906, Culture=neutral, PublicKeyToken=null]]. Registering generic types with ObjectiveC is not supported.} MonoTouch.MonoTouchException ` – Kevin Apr 04 '13 at 08:24
  • @Kevin: yes, it regressed and it will be fixed in a later release. In the meantime you can pass "--registrar:oldstatic" to mtouch (in the additional mtouch arguments in the project's iOS Build options). – Rolf Bjarne Kvinge Apr 04 '13 at 11:15