Bug 52474 - [iOS] Error MT4167: Cannot register the method 'get_DisabledDistanceHandlingClasses()' because the signature contains a generic type
Summary: [iOS] Error MT4167: Cannot register the method 'get_DisabledDistanceHandlingC...
Status: RESOLVED DUPLICATE of bug 52868
Alias: None
Product: iOS
Classification: Xamarin
Component: Tools ()
Version: XI 10.3 (iOS 10.2)
Hardware: PC Windows
: --- normal
Target Milestone: Future Cycle (TBD)
Assignee: Rolf Bjarne Kvinge [MSFT]
URL:
Depends on:
Blocks:
 
Reported: 2017-02-13 14:43 UTC by jramos
Modified: 2017-03-01 10:51 UTC (History)
4 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED DUPLICATE of bug 52868

Description jramos 2017-02-13 14:43:36 UTC
When I try to build the solution using Debug or Release for iPhone I'm getting the following errors:

(Build) ->
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/iOS/Xamarin.iOS.Common.targets (_CompileToNative target) ->

	MTOUCH: error MT4167: Cannot register the method 'get_DisabledDistanceHandlingClasses()' because the signature contains a generic type (Foundation.NSMutableSet`1<ObjCRuntime.Class>) with a generic argument type that isn't an NSObject subclass (ObjCRuntime.Class).
	MTOUCH: error MT4167: Cannot register the method 'get_DisabledToolbarClasses()' because the signature contains a generic type (Foundation.NSMutableSet`1<ObjCRuntime.Class>) with a generic argument type that isn't an NSObject subclass (ObjCRuntime.Class).
	MTOUCH: error MT4167: Cannot register the method 'get_DisabledTouchResignedClasses()' because the signature contains a generic type (Foundation.NSMutableSet`1<ObjCRuntime.Class>) with a generic argument type that isn't an NSObject subclass (ObjCRuntime.Class).
	MTOUCH: error MT4167: Cannot register the method 'get_EnabledDistanceHandlingClasses()' because the signature contains a generic type (Foundation.NSMutableSet`1<ObjCRuntime.Class>) with a generic argument type that isn't an NSObject subclass (ObjCRuntime.Class).
	MTOUCH: error MT4167: Cannot register the method 'get_EnabledToolbarClasses()' because the signature contains a generic type (Foundation.NSMutableSet`1<ObjCRuntime.Class>) with a generic argument type that isn't an NSObject subclass (ObjCRuntime.Class).
	MTOUCH: error MT4167: Cannot register the method 'get_EnabledTouchResignedClasses()' because the signature contains a generic type (Foundation.NSMutableSet`1<ObjCRuntime.Class>) with a generic argument type that isn't an NSObject subclass (ObjCRuntime.Class).
	MTOUCH: error MT4167: Cannot register the method 'get_ToolbarPreviousNextAllowedClasses()' because the signature contains a generic type (Foundation.NSMutableSet`1<ObjCRuntime.Class>) with a generic argument type that isn't an NSObject subclass (ObjCRuntime.Class).

However when I build the solution for the Simulator, it works fine.

I'm using:

Microsoft Visual Studio Community 2015 Version 14.0.25431.01 Update 3

Microsoft .NET Framework Version 4.6.01586

Xamarin.iOS   10.3.1.8 (7beaef4)

XCode Version 8.2.1 (8C1002)
Comment 1 Rolf Bjarne Kvinge [MSFT] 2017-02-13 15:48:26 UTC
Currently we only support generic types where the generic type argument is a class derived from NSObject.

The type 'Class' isn't derived from NSObject, which means it can't be used as a generic type argument like this: NSMutableSet<Class>.

The workaround is to use the non-generic version (NSMutableSet).
Comment 2 jramos 2017-02-13 16:50:36 UTC
Thanks for the update. However why is this compiling and runing fine in the simulator but when I try to run it on the device it gives me this problem?
Comment 3 Rolf Bjarne Kvinge [MSFT] 2017-02-14 13:49:46 UTC
That's probably a bug when we run in the simulator, the behavior should be identical.
Comment 4 jramos 2017-02-14 18:48:52 UTC
Thanks for the clarification. I was able to solve this. The problem was with a 3rd party library binding.
Comment 5 Jacob 2017-02-24 17:41:50 UTC
I'm seeing the same error. jramos was it IQKeyboardManager? How did you solve the problem?
Comment 6 jramos 2017-02-24 19:29:35 UTC
Hi Jacob. In our case the problem was that we were using the package "IQKeyboardManager.Touch v4.0.1". We switched to "Xamarin.IQKeyboardManager v1.1" and we were able to build the app for iPhone. Using the first package and building for simulator worked just fine.
Hope this helps.
Comment 7 Andrew Polkinghorn 2017-02-27 09:15:12 UTC
Hello,

Is there an estimate on when generic types will support objects that don't inherit from NSObject?

I am a team working on an Objective-C framework that we provide Xamarin bindings for & we have the following api on one of our objects:

NSSet<id<SChartData>> *selectedDataPoints;

We have users that are getting this error when they attempt to create an archive build of their apps or build to a device.

Our current work around is to tell users to build with a previous version of Xamarin Studio.

I look forward to your response.

Kind regards,
Andrew Polkinghorn.
Comment 8 Rolf Bjarne Kvinge [MSFT] 2017-02-27 16:38:22 UTC
(In reply to Andrew Polkinghorn from comment #7)
> Hello,
> 
> Is there an estimate on when generic types will support objects that don't
> inherit from NSObject?
> 
> I am a team working on an Objective-C framework that we provide Xamarin
> bindings for & we have the following api on one of our objects:
> 
> NSSet<id<SChartData>> *selectedDataPoints;
> 
> We have users that are getting this error when they attempt to create an
> archive build of their apps or build to a device.
> 
> Our current work around is to tell users to build with a previous version of
> Xamarin Studio.

We've never supported what you need, so how did you bind this so that it only works with previous versions of Xamarin.iOS?
Comment 9 Andrew Polkinghorn 2017-03-01 10:28:45 UTC
Hi Rolf,

This is the current binding for that property:

// @property (nonatomic, strong) NSSet<id<SChartData>> * _Nonnull selectedDataPoints;
[Export("selectedDataPoints", ArgumentSemantic.Strong)]
NSSet<ISChartData> SelectedDataPoints { get; set; }

Xamarin.iOS Version: 10.3.1.8 builds successfully on to a device.

Xamarin.iOS Version: 10.4.0.123 presents the build errors mentioned at the start of this ticket.

Kind regards,
Andrew Polkinghorn.
Comment 10 Rolf Bjarne Kvinge [MSFT] 2017-03-01 10:51:05 UTC
So it turns out this is indeed a regression in Xamarin.iOS 10.4.

@jramos, I'm not sure how you managed to reproduce this with 10.3.1.8, because this error (MT4167) doesn't exist in that version of Xamarin.iOS.

The regression has already been fixed, and will be included in the first service release.

*** This bug has been marked as a duplicate of bug 52868 ***