This is a weird problem: app suddenly started to crash but there is no reason. Let me explain.
I'm developing a simple app on iOS (with Visual Studio for Mac) on MacOS and it worked well until yesterday but after some code modifications (reformat code and added 2 classes, nothing more) it started crashing when performing segue or presenting view controller.
I tried to clean solution, delete bin
and object
folders, removing and reinstalling the app (both from simulator and\or device), reset to a previous knowing working version (git) but no luck at all: app starts, I push login (or other button that changes current ViewController) and it crashes.
Exception details are clear:
Objective-C exception thrown. Name: NSInternalInconsistencyException Reason: Could not load NIB in bundle: 'NSBundle "/Users/Izzu/Library/Developer/CoreSimulator/Devices/AF902EFF-4737-4A04-A238-40FBA092ABC2/data/Containers/Bundle/Application/E7FB6ED2-384B-4971-9FDE-0E2D11A161D3/MY_APP.app" (loaded)' with name 'MMC-nl-GEi-view-twi-04-tAp'
But this is the problem: ViewController called from button is named SignUpView
. There is an associated class with same name and storyboardIdentifier is the same. Checking the storyboard xml I can see that the ViewController's id that will be presented is "MMC-nl-GEi"
and the main view id contained in it is "twi-04-tAp"
so I don't understand where is the problem.
It worked until previous day as all other transitions (I have many ViewControllers with storyboardIdentifier with correct names and I worked with them almost everyday until yesterday) and worst thing is that resetting to a previous version doesn't solve.
Details:
- All ViewControllers are in the same storyboard, the one loaded when app starts.
- Transitions to viewControllers are default iOS transitions: no custom component or effect.
Transitions are performed with segue or by PresentViewController method, both crashes
Debugging code
var PinViewController = this.Storyboard.InstantiateViewController("PinViewController"); PinViewController.ModalPresentationStyle = UIModalPresentationStyle.OverCurrentContext; PinViewController.ModalTransitionStyle = UIModalTransitionStyle.CoverVertical; this.PresentViewController(PinViewController, true, null);
shows that PinViewController
is not null and it is the correct one.
I tried creating another sample app with segues and PresentViewController
and it is working so I think it is app\project related problem, but doesn't explain why resetting to a one week ago version is not fixing it.
Software details:
- MacOS High Sierra (10.13.1)
- Visual Studio for Mac 7.2.2
- Mono 5.4.1.6 (2017-06/1f4613aa1ac) (64-bit)
- Xamarin iOS Version: 11.2.0.11 (Visual Studio Enterprise)
- XCode 9.0.1
I tried on another Mac with updated Xamarin iOS (11.2.1.0) and updated XCode (9.1) but problem is still present.
Someone can point me to the right way? Right now I tried almost everything and I'm stil stuck at same point...
UPDATE
I tried to add a new ViewController in the storyboard and connected a segue to it and id worked. I checked differences and I found that new VC has a numeric id instead alpha numeric (5028 instead PFz-cV-xIy). I tried to change an existent VC id to a new one (not used) and it's internal view as well: same error
Objective-C exception thrown. Name: NSInternalInconsistencyException Reason: Could not load NIB in bundle: 'NSBundle "/Users/Izzu/Library/Developer/CoreSimulator/Devices/AF902EFF-4737-4A04-A238-40FBA092ABC2/data/Containers/Bundle/Application/E7FB6ED2-384B-4971-9FDE-0E2D11A161D3/MY_APP.app" (loaded)' with name '5027-view-5029'
It seems and I don't know why it's searching a nib called VIEWCONTROLLERID-view-MAINVIEWID but only on "old" view controllers, with new created one there are no problem and the only differences between them is the numeric id.
I will continue to investigate and I will update this question to be clearer and to help is someone has same problem.
UPDATE 2
I found that entities in storyboard xml have numeric id when created by Visual Studio for Mac designer and alphanumeric id when create by Xcode so it is not relevant to the main problem.