diff --git a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterViewController.mm b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterViewController.mm index 993d7327a3..891877220c 100644 --- a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterViewController.mm +++ b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterViewController.mm @@ -390,21 +390,43 @@ - (UIView*)splashScreenView { if (_splashScreenView == nullptr) { - NSString* launchStoryboardName = + NSString* launchscreenName = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"UILaunchStoryboardName"]; - if (launchStoryboardName == nil) { + if (launchscreenName == nil) { return nil; } - UIStoryboard* storyboard = [UIStoryboard storyboardWithName:launchStoryboardName bundle:nil]; - if (storyboard == nil) { - return nil; + UIView* splashView = [self splashScreenFromStoryboard:launchscreenName]; + if (!splashView) { + splashView = [self splashScreenFromXib:launchscreenName]; } - UIViewController* splashScreenViewController = [storyboard instantiateInitialViewController]; - self.splashScreenView = splashScreenViewController.view; + self.splashScreenView = splashView; } return _splashScreenView.get(); } +- (UIView*)splashScreenFromStoryboard:(NSString*)name { + UIStoryboard* storyboard = nil; + @try { + storyboard = [UIStoryboard storyboardWithName:name bundle:nil]; + } @catch (NSException* exception) { + return nil; + } + if (storyboard) { + UIViewController* splashScreenViewController = [storyboard instantiateInitialViewController]; + return splashScreenViewController.view; + } + return nil; +} + +- (UIView*)splashScreenFromXib:(NSString*)name { + NSArray* objects = [[NSBundle mainBundle] loadNibNamed:name owner:self options:nil]; + if ([objects count] != 0) { + UIView* view = [objects objectAtIndex:0]; + return view; + } + return nil; +} + - (void)setSplashScreenView:(UIView*)view { _splashScreenView.reset([view retain]); _splashScreenView.get().autoresizingMask =