Bug 4467 - MonoDevelop error generating Xcode project: could not generate outlet as its type could not be resolved to Objective-C
Summary: MonoDevelop error generating Xcode project: could not generate outlet as its ...
Alias: None
Product: Xamarin Studio
Classification: Desktop
Component: iOS add-in ()
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: ---
Assignee: Jeffrey Stedfast
Depends on:
Reported: 2012-04-16 13:07 UTC by jesse.attas
Modified: 2012-04-26 15:57 UTC (History)
4 users (show)

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:

Description jesse.attas 2012-04-16 13:07:12 UTC
Various members of my team get this error dialog periodically when trying to open a XIB file from MonoDevelop.

We haven't been able to track down exactly what causes the error to appear. The basic setup is a directory of custom view controllers (each with .cs, .designer.cs, .xib). Some of the XIB files contain outlets that are custom UIViews. The custom UIViews live in a different assembly and namespace from the view controllers. It is these outlets that Xcode can't resolve. It seems like it happens when one team member modifies either one of the view controllers or one of the custom views.

Once the error appears then the only thing that fixes it is force-syncing the directories containing the XIBs and the custom views. Some things that don't fix the problem include: restarting MonoDevelop, restarting Xcode, deleting the directory containing the generated Xcode project.

Here's the text of the error:

An error has occurred:
Error updating Xcode project. Could not generate outlet 'MyOutletThatsACustomUIView' in class 'MyCompany.MyNamespace.MyUIViewController' as its type 'MyCompany.MyOtherNamespace.MyCustomUIView' could not be resolved to Obj-C

MonoDevelop.MacDev.ObjCIntegration.ObjectiveCGenerationException: Could not generate outlet 'MyOutletThatsACustomUIView' in class 'MyCompany.MyNamespace.MyUIViewController' as its type 'MyCompany.MyOtherNamespace.MyCustomUIView' could not be resolved to Obj-C
  at MonoDevelop.MacDev.ObjCIntegration.NSObjectTypeInfo.GenerateObjcType (System.String directory, System.String[] frameworks) [0x001e8] in /Users/builder/data/lanes/monodevelop-mac- 
  at MonoDevelop.MacDev.XcodeSyncing.XcodeSyncedType.SyncOut (IProgressMonitor monitor, MonoDevelop.MacDev.XcodeSyncing.XcodeSyncContext context) [0x0001b] in /Users/builder/data/lanes/monodevelop-mac- 
  at MonoDevelop.MacDev.XcodeSyncing.XcodeMonitor.UpdateProject (IProgressMonitor monitor, System.Collections.Generic.List`1 allItems, MonoDevelop.MacDev.XcodeIntegration.XcodeProject emptyProject) [0x002e3] in /Users/builder/data/lanes/monodevelop-mac- 
  at MonoDevelop.MacDev.XcodeSyncing.XcodeProjectTracker.UpdateXcodeProject (IProgressMonitor monitor) [0x00000] in /Users/builder/data/lanes/monodevelop-mac-
Comment 1 jesse.attas 2012-04-16 13:22:30 UTC
This has been happening through a few MonoTouch updates, but here's my current version info:
Installation UUID: 1480f558-ce01-4cc9-8f58-058dda76f061
	Mono 2.10.9 (tarball Tue Mar 20 15:31:37 EDT 2012)
	GTK 2.24.10
	GTK# (
Apple Developer Tools:
	 Xcode 4.3.1 (1176)
	 Build 4E1019
Monotouch: 5.2.10
Mono for Android not installed
Comment 2 Jeffrey Stedfast 2012-04-19 11:49:23 UTC
Someone else just hit this on the mailing-list as well and I'd really like to solve this but I have no idea what is causing this to happen.

If this happens again, would it be possible for you to zip up your project and let us take a look at it and see what is going wrong?

If you attach it here, you can mark it as private by checking the checkbox labeled "Make attachment and comment private" (you'll see it on the "Add an attachment" screen).
Comment 4 Jeffrey Stedfast 2012-04-19 19:04:29 UTC
I was just look at this code and trying to help someone else with their project and hit something similar.

Take a look at MyCompany.MyOtherNamespace.MyCustomUIView and make sure that it has a [Register] attribute on the class definition.

That should fix the issue.

Now the question is whether or not we can work around users not tagging some of their custom base classes with [Register]...
Comment 5 jesse.attas 2012-04-20 10:16:37 UTC
All of the views I've checked do have the [MonoTouch.Foundation.Register("MyCustomUIView")] attribute. In some cases, the attribute is inside a #if block (but the enabled case of it, so I don't think that should matter).
Comment 6 jesse.attas 2012-04-20 10:34:46 UTC
I was able to reproduce this again. I tried to zip up my project to send it to you, but found it's not reproducible after unzipping the zipped project! I also tried copying some parts of my project to a new directory, but the bug disappeared in that copy too. However, the original project still exhibits the error (but I'm guessing that force syncing the directories containing the XIBs and custom views will fix it again).

Let me know if there's anything else I can try.
Comment 7 Jeffrey Stedfast 2012-04-20 17:51:42 UTC

*** This bug has been marked as a duplicate of bug 4562 ***
Comment 8 Dermot 2012-04-20 22:12:47 UTC
I have checked if the [Register] attribute was on my classes and indeed it was. However this morning it just magically started working again. If it makes any difference, the debugger was running and connected to the simulator when I tried to open the xib.

Once it opened successfully, it seems to continue working again afterwards, even if the debugger isn't running. Im not sure if this is a coincidence, but just thought id mention it.
Comment 9 Jeffrey Stedfast 2012-04-23 11:52:07 UTC
As a temporary workaround, could you guys try deleting all of the *.pidb files in your project?

These files are auto-generated by MonoDevelop and may be corrupt, which might be causing the problem you guys are seeing.
Comment 10 Jeffrey Stedfast 2012-04-23 11:55:15 UTC
Oh, I should maybe re-word my previous comment:

Instead of deleting them, perhaps you could just move them somewhere else so that you can send them to us if this does actually fix the problem.

Someone else who reported this issue to me on friday emailed me back saying that deleting his *.pidb files fixed it for him (after I suggested that he could try that).
Comment 12 Jeffrey Stedfast 2012-04-26 15:57:26 UTC
This is fixed in MonoDevelop 2.9.5 alpha