iOS exception
pieterdhondt opened this issue · comments
When trying to run the Mobile.iOS application in the iOS simulator as-is, I get an exception:
Objective-C exception thrown. Name: NSInternalInconsistencyException Reason: Application windows are expected to have a root view controller at the end of application launch
Native stack trace:
0 CoreFoundation 0x0000000103011f45 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x000000010b1b7deb objc_exception_throw + 48
2 CoreFoundation 0x0000000103011daa +[NSException raise:format:arguments:] + 106
3 Foundation 0x00000001036825ee -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 198
4 UIKit 0x00000001059ecf15 -[UIApplication _runWithMainScene:transitionContext:completion:] + 3112
5 UIKit 0x00000001059e9ba3 -[UIApplication workspaceDidEndTransaction:] + 188
6 FrontBoardServices 0x000000010da2b784 -[FBSSerialQueue _performNext] + 192
7 FrontBoardServices 0x000000010da2baf2 -[FBSSerialQueue _performNextFromRunLoopSource] + 45
8 CoreFoundation 0x0000000102f3e011 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
9 CoreFoundation 0x0000000102f33f3c __CFRunLoopDoSources0 + 556
10 CoreFoundation 0x0000000102f333f3 __CFRunLoopRun + 867
11 CoreFoundation 0x0000000102f32e08 CFRunLoopRunSpecific + 488
12 UIKit 0x00000001059e94f5 -[UIApplication _run] + 402
13 UIKit 0x00000001059ee30d UIApplicationMain + 171
14 ??? 0x000000011c2e4f9b 0x0 + 4767764379
15 ??? 0x000000011c2e4c85 0x0 + 4767763589
Any thoughts on what's going wrong? The Mobile.Droid app runs without problems in the simulator by the way.
I don't have my Mac build host handy at the moment but I have a feeling what it could be.
In the Mobile project go to App.xaml.cs and in the constructor after InitializeComponent() add in this line
App.Current.MainPage = new ContentPage();
Let me know if that works, then I will update the project and check-in. Otherwise I will need to wait until tomorrow to get testing on it.
That worked! Thanks :-)
Can App.Current.MainPage = new ContentPage();
be removed? It causes a flicker on launch because of it. How can we update the code so it doesn't have to open this blank page first but the first stack instead?
EDIT: I got around it by loading the stack in the constructor using https://gist.github.com/rid00z/96b875f096cbc7cbcba8 to run the task synchronously.
thanks @michaeldimoudis for your workaround. I will look into it further this week and make an update. I dislike flickers as much as the next person :)