Bug 1495 - Creating a new file of type Monotouch/iPhone View does not create designer files
Summary: Creating a new file of type Monotouch/iPhone View does not create designer files
Alias: None
Product: Xamarin Studio
Classification: Desktop
Component: iOS add-in ()
Version: 2.8
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: ---
Assignee: Alan McGovern
Depends on:
Reported: 2011-10-14 08:48 UTC by Matt Jones
Modified: 2011-10-18 05:06 UTC (History)
2 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 Matt Jones 2011-10-14 08:48:20 UTC
Creating a new file of type Monotouch/iPhone View does not create designer files.

If I create a new file in my project of type 'iPhone View', the XIB is created but no designer.cs file is created. Hence when I click on the XIB to edit, I can't create outlets in XCode 4 because there is no .h file.

If I do the same but create a new file with type 'iPhone View Controller', the designer.cs file is created and everything works OK.

If you have a work-around it would be very useful.
Comment 1 Mikayla Hutchinson [MSFT] 2011-10-18 04:41:36 UTC
This is by design. In Xcode 4, xibs cannot define custom classes, so xibs no longer have designer files.  Xcode reads type information from Objective-C source instead. Therefore, MD syncs to Xcode all the classes that would be visible to Objective-C. That means that these *classes* have designer files.

You have created a view defined in a xib. A xib is simply a serialized object graph, and the view in the template doesn't use or define any custom types.

If you want to give your view object in the xib a custom class, define the class in MD and register with the obj-C runtime, e.g.
class MyView : UIView

Then, when you open the xib in Xcode again, the MyView type will be visible, and you can look at the UIView in the xib and set its custom class to MyView.

You can do this for all widgets in the xib. The only reason the UIViewController template creates a custom class for the view controller by default is that a view controller needs to be a custom class of some kind. However, views don't need to be custom types - for example, you might set the xib File's Owner to some existing view controller type, and connect the view's widgets to the controller's outlets.
Comment 2 Matt Jones 2011-10-18 05:06:36 UTC
Thanks, that is very helpful, excellent explanation. I really like the way that works.