Bug 27990 - Can't load NIB when XIB is in a subfolder of the project.
Summary: Can't load NIB when XIB is in a subfolder of the project.
Alias: None
Product: Visual Studio Extensions
Classification: Xamarin
Component: iOS ()
Version: 3.9
Hardware: PC Windows
: --- normal
Target Milestone: 3.9.4 (C4SR4)
Assignee: Adrian Alonso
Depends on:
Reported: 2015-03-12 18:35 UTC by Jon Goldberger [MSFT]
Modified: 2015-03-24 04:42 UTC (History)
15 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 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 Jon Goldberger [MSFT] 2015-03-12 18:35:46 UTC
## Bug description

I have had two customers that can't launch iOS projects after updating to Xamarin for VS 3.9 / iOS 8.8. After a bit of investigation of the full projects they sent, I found that moving the XIB files to the root of the project resolved the issue with loading the NIBs. When the XIB files were in a subfolder, the launch failed with exception:

>Foundation.MonoTouchException: Objective-C exception thrown. Name: NSInternalInconsistencyException Reason: Could not load NIB in bundle: 'NSBundle </Users/apple/Library/Developer/CoreSimulator/Devices/AE79671E-2B9E-4DDA-87EB-899CFE132DEA/data/Containers/Bundle/Application/A82734AC-FF5E-45D1-A416-FFBD36DD2324/InfoChipMobileiOS.app> (loaded)' with name 'LicenseAgreementScreen_iPhone'

The issue can be reproduced with the "Hello_MultiScreen_iPhone mono touch sample project: https://github.com/xamarin/monotouch-samples/tree/master/Hello_MultiScreen_iPhone

## Steps to reproduce:

1. Open the Hello_MultiScreen_iPhone sample app into Visual Studio. Make sure you have Xamarin version 3.9 installed.

2. Deploy to an iPhone simulator.

Expected result: App will launch and UI will be displayed.

Actual result: App launches but no UI is displayed and gets the exception noted above.

3. To confirm that the case is the placement of the xib files in a subfolder, move all three of the xib files from the Screens folder to the root of the project.

4. Relaunch the app.

Expected result: App will launch and UI will be displayed.

Actual result: as expected.

## Notes

This issue does not occur in Xamarin Studio on the Mac.
Comment 2 Jon Goldberger [MSFT] 2015-03-12 18:40:06 UTC
Might be related to https://bugzilla.xamarin.com/show_bug.cgi?id=19453
Comment 3 Jon Goldberger [MSFT] 2015-03-12 18:46:51 UTC
Workaround for this bug is to move the XIB files to the root of the project.
Comment 4 Jon Goldberger [MSFT] 2015-03-12 19:02:44 UTC
VS Version info:

Microsoft Visual Studio Ultimate 2013
Version 12.0.31101.00 Update 4
Microsoft .NET Framework
Version 4.5.53349

Installed Version: Ultimate

Architecture and Modeling Tools   06181-004-0451031-02209
Microsoft Architecture and Modeling Tools
UML® and Unified Modeling Language™ are trademarks or registered trademarks of the Object Management Group, Inc. in the United States and other countries.

LightSwitch for Visual Studio 2013   06181-004-0451031-02209
Microsoft LightSwitch for Visual Studio 2013

Team Explorer for Visual Studio 2013   06181-004-0451031-02209
Microsoft Team Explorer for Visual Studio 2013

Visual Basic 2013   06181-004-0451031-02209
Microsoft Visual Basic 2013

Visual C# 2013   06181-004-0451031-02209
Microsoft Visual C# 2013

Visual C++ 2013   06181-004-0451031-02209
Microsoft Visual C++ 2013

Visual F# 2013   06181-004-0451031-02209
Microsoft Visual F# 2013

Visual Studio 2013 Code Analysis Spell Checker   06181-004-0451031-02209
Microsoft® Visual Studio® 2013 Code Analysis Spell Checker

Portions of International CorrectSpell™ spelling correction system © 1993 by Lernout & Hauspie Speech Products N.V. All rights reserved.

The American Heritage® Dictionary of the English Language, Third Edition Copyright © 1992 Houghton Mifflin Company. Electronic version licensed from Lernout & Hauspie Speech Products N.V. All rights reserved.

Windows Phone SDK 8.0 - ENU   06181-004-0451031-02209
Windows Phone SDK 8.0 - ENU

Application Insights Tools for Visual Studio Package   1.0
Application Insights Tools for Visual Studio

ASP.NET and Web Tools   12.4.51016.0
Microsoft Web Developer Tools contains the following components:
Support for creating and opening ASP.NET web projects
Browser Link: A communication channel between Visual Studio and browsers
Editor extensions for HTML, CSS, and JavaScript
Page Inspector: Inspection tool for ASP.NET web projects
Scaffolding: A framework for building and running code generators
Server Explorer extensions for Microsoft Azure Websites
Web publishing: Extensions for publishing ASP.NET web projects to hosting providers, on-premises servers, or Microsoft Azure

ASP.NET Web Frameworks and Tools 2012.2   4.1.21001.0
For additional information, visit http://go.microsoft.com/fwlink/?LinkID=309563

ASP.NET Web Frameworks and Tools 2013   5.2.21010.0
For additional information, visit http://www.asp.net/

Common Azure Tools   1.3
Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.

Microsoft Advertising SDK for Windows Phone   
Microsoft Advertising SDK for Windows Phone

Microsoft Azure HDInsight HQL Service   1.0.0000.0
Language service for Hive query

Microsoft Azure HDInsight Tools for Visual Studio   1.0.0000.0
An integrated development environment for HDInsight application development.

Microsoft Azure Mobile Services Tools   1.3
Microsoft Azure Mobile Services Tools

Microsoft Azure Tools   2.4
Microsoft Azure Tools for Microsoft Visual Studio 2013 - v2.4.20730.1601

Microsoft Azure Tools   2.5
Microsoft Azure Tools for Microsoft Visual Studio 2013 - v2.5.21104.1601

Multilingual App Toolkit   3.1.1250.0
Multilingual App Toolkit helps you localize your Windows Store app by providing file management, pseudo and machine translation, translation editor, and build integration. http://go.microsoft.com/fwlink?linkid=245767

NuGet Package Manager   2.8.50926.663
NuGet Package Manager in Visual Studio. For more information about NuGet, visit http://docs.nuget.org/.

Office Developer Tools for Visual Studio 2013 ENU   12.0.31105
Microsoft Office Developer Tools for Visual Studio 2013 ENU

PowerShell Tools   1.3
Provides file classification services using PowerShell

PreEmptive Analytics Visualizer   1.2
Microsoft Visual Studio extension to visualize aggregated summaries from the PreEmptive Analytics product.

SQL Server Data Tools   12.0.41025.0
Microsoft SQL Server Data Tools

Windows Azure Tools   2.3
Windows Azure Tools for Microsoft Visual Studio 2013 - v2.3.20320.1602

Windows Phone 8.1 SDK Integration   1.0
This package integrates the tools for the Windows Phone 8.1 SDK into the menus and controls of Visual Studio.

Workflow Manager Tools 1.0   1.0
This package contains the necessary Visual Studio integration components for Workflow Manager.

Xamarin   3.9.483.0 (978be3d)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.

Xamarin.Android (9e05e39f02bafe8fc0b7ab025d99f3b446835ad4)
Visual Studio plugin to enable development for Xamarin.Android.

Xamarin.iOS (702be5207a1446b066f4653f68739da13c045227)
Visual Studio extension to enable development for Xamarin.iOS.

Xamarin.iOS Unified Migration   1.0
Automated migration for Xamarin iOS Classic projects to Unified

Xamarin Studio version info (Mac):

=== Xamarin Studio ===

Version 5.8 (build 443)
Installation UUID: 2dc9022f-f9a8-424f-8284-bf224cbbfde0
	Mono 3.12.1 ((detached/b7764aa)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 312010000

=== Apple Developer Tools ===

Xcode 6.2 (6776)
Build 6C131e

=== Xamarin.Mac ===

Version: (Business Edition)

=== Xamarin.Android ===

Version: (Business Edition)
Android SDK: /Users/apple/Library/Developer/Xamarin/android-sdk-mac_x86
	Supported Android versions:
		2.2    (API level 8)
		2.3    (API level 10)
		3.1    (API level 12)
		4.0    (API level 14)
		4.0.3  (API level 15)
		4.1    (API level 16)
		4.2    (API level 17)
		4.3    (API level 18)
		4.4    (API level 19)
		4.4.87 (API level 20)
		5.0    (API level 21)
Java SDK: /usr
java version "1.6.0_65"
Java(TM) SE Runtime Environment (build 1.6.0_65-b14-466.1-11M4716)
Java HotSpot(TM) 64-Bit Server VM (build 20.65-b04-466.1, mixed mode)

=== Xamarin Android Player ===

Version: Unknown version
Location: /Applications/Xamarin Android Player.app

=== Xamarin.iOS ===

Version: (Business Edition)
Hash: ccfcd59
Build date: 2015-03-10 02:20:32-0400

=== Build Information ===

Release ID: 508000443
Git revision: 73883239470cbe8e261c94d95f7c3d0452fd393b
Build date: 2015-03-10 07:22:51-04
Xamarin addins: a2ff7b617f09d9c45d8bbf3d010b5db0d7d36100

=== Operating System ===

Mac OS X 10.10.2
Darwin Jons-iMac.local 14.1.0 Darwin Kernel Version 14.1.0
    Thu Feb 26 19:26:47 PST 2015
    root:xnu-2782.10.73~1/RELEASE_X86_64 x86_64
Comment 5 Brendan Zagaeski (Xamarin Team, assistant) 2015-03-12 22:44:42 UTC
For reference, here's a corresponding forum thread:

I added a link to this bug report on that thread.
Comment 11 Brendan Zagaeski (Xamarin Team, assistant) 2015-03-17 13:37:26 UTC
Regression status: Regression between Xamarin 3.9.347.0 (056cf9e) + Xamarin.iOS for Mac (90e32d0) and Xamarin 3.9.483.0 (978be3d) + Xamarin.iOS for Mac (ccfcd59)

(i.e., a regression in the WatchKit release)

## Actual results

The behavior described in comment 10 is the same as what happens currently in Xamarin 3.9.483.0 (978be3d). The `.nib` files are copied into a `Screens/` subfolder within the `.app` bundle, rather than being copied to the topmost directory of the `.app` bundle.

This isn't _necessarily_ wrong, but it is a breaking change, so if it needs to change, then ideally (a) the change should happen within Xamarin Studio and Visual Studio at the same time, (b) it should be loudly announced to customers, and (c) it should perhaps be held until a major feature release (unless it's absolutely required for WatchKit support).

## Expected results

- Xamarin Studio 5.8 (build 443) + Xamarin.iOS for Mac (ccfcd59) copies the `.nib` files to the topmost directory of the `.app` bundle.

- Xamarin 3.9.347.0 (056cf9e) + Xamarin.iOS for Mac (90e32d0) also copies the `.nib` files to the topmost directory of the `.app` bundle.
Comment 12 PJ 2015-03-17 16:18:09 UTC
@Adrian Alonso, I'm not sure why we aren't returning to the previous behavior, as it caused confusion to customers and was not fully documented.

One reason would be that this change is happening for both XVS and XS, but it looks like it's not done in XS. Can we coordinate the change and release the change together with updated docs?

Then we could return to the previous behavior for C4SR4 and settle the existing complaints. REOPENing so we can discuss.
Comment 13 Mikayla Hutchinson [MSFT] 2015-03-17 16:18:20 UTC
Yes, this looks like a bad breaking change. InterfaceDefinition items should *not* be copied to subfolders (except .lproj), this was *by design*.
Comment 14 Adrian Alonso 2015-03-17 16:20:10 UTC
We're inheriting this behavior from maccore. So if we don't want it, we need to change the maccore targets.
Comment 16 Jeffrey Stedfast 2015-03-17 17:22:51 UTC
commit 4089dcc1244ea582146b74b6a5fcba8ba3b38842
Author: Jeffrey Stedfast <jeff@xamarin.com>
Date:   Tue Mar 17 17:18:44 2015 -0400

    [msbuild] Revert change that computed IB app bundle paths based on LogicalNames
    Fixes bug #27990
Comment 17 Daniel Smith 2015-03-18 09:14:21 UTC
I am being affected by this bug and I see it is now marked as resolved...sorry if I am being slow here, but reading the comments above - I am not clear on what the resolution is?  Surely we are not going to be forced to keep our storyboard files in the root folder of our project.
Comment 18 Jeffrey Stedfast 2015-03-18 09:51:40 UTC
No one is saying you need to put your xibs in the root of your project.

My comment above states that I have reverted my change that made the build system install your nib into Folder/MyView.nib instead of into the root of your app bundle.

However, even if I had not reverted my patch, it still would have been possible for you to keep your xib in a subfolder and have it be installed into the root of your app bundle following the same rules that you can already use for images, which is that you could assign a LogicalName property to your xib file to make it get installed into the root of your app bundle.

For example, this will work for you Right Now(tm):

Edit your .csproj in a text editor and find your .xib file, let's pretend that it looks like this:

<InterfaceDefinition Include="Folder\MyView.xib" />

What you can do, is change it to this:

<InterfaceDefinition Include="Folder\MyView.xib">

More info here:

Comment 19 Daniel Smith 2015-03-18 11:52:11 UTC
Ok, thanks for the clarification - I will give this a try!
Comment 21 Saurabh 2015-03-24 04:42:11 UTC
I have checked this Issue with latest build of C4SR4. I am getting both buttons for sample Hello_MultiScreen_iPhone. on iOS Simulator. This is the screencast for the same: http://www.screencast.com/t/3KmFhsfV

Microsoft Visual Studio Professional 2013
Version 12.0.31101.00 Update 4
Microsoft .NET Framework
Version 4.5.51641
Installed Version: Professional
Xamarin   3.9.534.0 (bb0518b)