Bug 3591 - Using NIB based windows in Libraries doesn't work
Summary: Using NIB based windows in Libraries doesn't work
Status: RESOLVED INVALID
Alias: None
Product: iOS
Classification: Xamarin
Component: General ()
Version: 5.2
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2012-02-22 11:55 UTC by Chris Hamons
Modified: 2012-04-13 07:33 UTC (History)
6 users (show)

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


Attachments
Example of Problem under Mono Touch (1.35 MB, application/zip)
2012-02-22 11:55 UTC, Chris Hamons
Details
Same issue under MonoMac (4.86 MB, application/octet-stream)
2012-02-22 11:56 UTC, Chris Hamons
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 INVALID

Description Chris Hamons 2012-02-22 11:55:56 UTC
Created attachment 1403 [details]
Example of Problem under Mono Touch

We're having difficulty using any NIB based dialogs that are stored in projects outside of the "Executable" project in MonoTouch and MonoMac. I've attached an example for MonoTouch.
Comment 1 Chris Hamons 2012-02-22 11:56:45 UTC
Created attachment 1404 [details]
Same issue under MonoMac
Comment 2 Rolf Bjarne Kvinge [MSFT] 2012-02-22 16:20:42 UTC
I'm not entirely sure about this, but I don't think this is a supported scenario.
Comment 3 Mikayla Hutchinson [MSFT] 2012-02-22 16:46:46 UTC
It is supported for MonoTouch, but not for MonoMac.

MD embeds the nibs into the dll with an encoded name when building the library, and unpacks them when building the app. mtouch then strips the resources from the linked dlls.

The nibs from the library appear to have been unpacked into the app bundle, what's not working?
Comment 4 Chris Hamons 2012-02-22 16:59:51 UTC
Try running the MonoTouch example, you don't see the label that Library.MyControls's nib has. Open up AppDelegate.cs and compare the commented out code (that works) with the uncommented out code (that doesn't).
Comment 5 Mikayla Hutchinson [MSFT] 2012-02-22 17:39:45 UTC
I wonder whether it has something to do with bug 3098?
Comment 6 Chris Hamons 2012-02-22 18:43:45 UTC
I think the root issue is that nib files not referenced in the main exe project don't seem to be deployed in the Contents/Resources directory.
Comment 7 Chris Hamons 2012-02-22 18:44:23 UTC
(Sorry for the bug spam).

If I add a reference to the nib file manually and force a rebuild it gets deployed.
Comment 8 Mikayla Hutchinson [MSFT] 2012-02-22 20:47:42 UTC
I assume you're talking about MonoMac in your last two comments? If so, could you please open a separate bug? It's a completely different issue.

MonoMac currently doesn't support bundling nibs from referenced projects and dlls. This feature would ideally be done the same way as MonoTouch if/when it's added.

MonoTouch is different because it's a supported feature, and the nibs appear to be copied into the output directory correctly. We need to dig deeper to find out why they're not working.
Comment 9 Chris Hamons 2012-02-23 10:58:09 UTC
Correct. I filed https://bugzilla.xamarin.com/show_bug.cgi?id=3611 for the MonoMac issue in particular.
Comment 10 Jeffrey Stedfast 2012-03-14 12:07:00 UTC
So I tested the demo and, as you said, it doesn't seem to work but I don't understand why not: the MyController_*.nib's are in the .app directory alongside the MonoTouchDemoViewController_*.nibs, which afaik is right where they should be, right?

Where does iOS expect them to be if not there?
Comment 11 Jeffrey Stedfast 2012-03-14 12:52:35 UTC
Interesting note: if I change the string passed to base() in the MyController ctor, I get an exception about the nib not being found in the app bundle.

So... since we're not getting that error if I leave that string unchanged, it suggests to me that the CocoaTouch libs are finding/loading it just fine.

So why aren't they loading the UI elements?
Comment 12 Jeffrey Stedfast 2012-03-14 12:59:47 UTC
Reassigning to the MonoTouch team as this doesn't appear to be anything that MonoDevelop is doing wrong.
Comment 13 Rolf Bjarne Kvinge [MSFT] 2012-04-13 07:33:25 UTC
There's a bug in your source code, for the library xib you do:

window.MakeKeyWindow ();

instead of 

window.MakeKeyAndVisible ();

This code works for me:

myController = new Library.MyController();
window.RootViewController = myController;
window.MakeKeyAndVisible();