Bug 25966 - Custom classes in interface definition file cannot be loaded at runtime in Unified API
Summary: Custom classes in interface definition file cannot be loaded at runtime in Un...
Status: RESOLVED FIXED
Alias: None
Product: iOS
Classification: Xamarin
Component: MSBuild ()
Version: XI 8.6.0
Hardware: Macintosh Mac OS
: Normal normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2015-01-13 06:43 UTC by Leon
Modified: 2016-05-26 21:16 UTC (History)
4 users (show)

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


Attachments
Diagnostic build log of broken build (377.62 KB, text/plain)
2015-01-13 08:03 UTC, Leon
Details
Diagnostic build log of working build (502.55 KB, text/plain)
2015-01-13 08:03 UTC, Leon
Details


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 FIXED

Description Leon 2015-01-13 06:43:40 UTC
Whenever I try to load a nib file that contains custom classes using (for example) the following piece of code:
var views = NSBundle.MainBundle.LoadNib("TTMainSideMenuCell",null,null);
TTMainSideMenuCell cell = Runtime.GetNSObject(  views.ValueAt(0) ) as TTMainSideMenuCell;

I get the exception: 
Objective-C exception thrown.  Name: NSUnknownKeyException Reason: [<UITableViewCell 0x79bdddd0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key mainBadgeView

This piece of code worked fine before switching to the Unified API and updating the outlets in XCode still
updates the designer file of the TTMainSideMenuCell class. 
For some reason the LoadNib method seems to be trying to hook up the outlets on the file's owner (which is null, as intended) instead of the TTMainSideMenuCell class as it did before.

This issue only occurs when the interface definition contains custom classes. When using a non-inherited UITableViewCell and other readily available classes in UIKit loading the nib works fine.

Just before the exception occurs the following errors appear in the output indicating that the custom classes in the interface definition cannot be found.

Unknown class TTMainSideMenuCell in Interface Builder file.
Unknown class MKBadgeView in Interface Builder file.

The classes shown in this error are both managed C# classes that should have been exposed to
ObjC/IB because of their [Register("<ClassName>")] attribute on their .designer
partial class. In the auto-generated XCode interface builder project these classes are visible and are shown to be properly hooked up to their respective layout elements.

Whenever this issue appears differs per build. Sometimes a clean and rebuild is enough to make the issue go away, only for it to seemingly randomly return sometime later. Sometimes rebooting Xamarin Studio and rebuilding is required.

The issue also seems to appear more often in i386 (Simulator) builds than ARM7 + ARM64 (Device) based builds.
Comment 1 Rolf Bjarne Kvinge [MSFT] 2015-01-13 06:49:49 UTC
Can you get build logs for a successful and a broken build so that we can compare them and see if there's something significant there?
Comment 2 Leon 2015-01-13 08:03:22 UTC
Created attachment 9335 [details]
Diagnostic build log of broken build
Comment 3 Leon 2015-01-13 08:03:42 UTC
Created attachment 9336 [details]
Diagnostic build log of working build
Comment 4 Rolf Bjarne Kvinge [MSFT] 2015-03-05 07:54:00 UTC
Comparing the output of the IBToolTask between the builds shows that the broken build doesn't invoke ibtool. This looks like a bug in our MSBuild logic.

Jeff, can you have a look?
Comment 5 Jeffrey Stedfast 2015-03-05 13:32:36 UTC
If it doesn't invoke ibtool, then it's because the timestamp on the output file is newer than the timestamp on the source file.

Try cleaning your build and then rebuilding.
Comment 6 Leon 2015-03-12 11:03:40 UTC
Cleaning and rebuilding didn't solve the issue. 
However, updating to the recently released Xamarin.iOS 8.8 did solve the issue. All custom classes are properly loaded again. (Tried on multiple machines and after multiple clean and rebuild cycles. Seems to be solved)

(Before this update our company used the Xamarin.iOS 8.6.1 release, where it was still broken)
Comment 7 Sebastien Pouliot 2016-05-26 21:16:15 UTC
Looks like XI 8.8 solved the problem. Closing