react-native-splash-screen icon indicating copy to clipboard operation
react-native-splash-screen copied to clipboard

iOS app crashes after splash screen is initialized version 3.2.0

Open patrikmasiar opened this issue 4 years ago • 12 comments

react: 16.9.0 react-native: 0.61.5

react-native-splash-screen: 3.2.0

iOs issue

Once the application starts and the splash screen is shown, the application freezes and it is not working then. The splash screen is not hidden and I can go into my application.

Error from Xcode: "Could not load NIB in bundle: 'NSBundle..."

Show splash screen in AppDelegate.m

...
[RNSplashScreen show];
[RNSplashScreen showSplash:@"LaunchScreen" inRootView:rootView];
...

patrikmasiar avatar Jun 29 '20 06:06 patrikmasiar

Any solution? Please help

metion avatar Jul 15 '20 06:07 metion

Running into this too. Having only [RNSplashScreen show]; in AppDelegate.m seems to work with getting the build to pass and run but I'm having issues with the SplashScreen hiding. The SplashScreen shows and never goes away. I verified in debug mode that the function to hide it is getting called in the correctly. Will circle back if I figure out the solution.

qflagg avatar Jul 19 '20 17:07 qflagg

We hit the same "Could not load NIB in bundle" error after upgrading to react-native 0.63 and switching from LaunchScreen.xib to LaunchScreen.storyboard.

In our case it was solved by switching the "Main Interface" under Targets -> General -> Deployment Info to LaunchScreen.storyboard (you've probably already done this for "Launch Screen File").

Screen Shot 2020-08-03 at 12 45 57 pm

rickgrundy avatar Aug 03 '20 02:08 rickgrundy

Same here

tronginc avatar Aug 14 '20 15:08 tronginc

@tronginc @rickgrundy @metion @massoprod

The issue is, Xcode project is now updated in 0.63 with UIView nib to UIViewController in LaunchScreen.storyboard which means the function in native has to update and change view loading from nib to view controller... Easy solution replace function showSplash with below given fixed code in file RNSplashScreen.m and set storyboard id see attachment below Now it won't crash :)

+ (void)showSplash:(NSString*)splashScreen inRootView:(UIView*)rootView {
    if (!loadingView) {
        UIStoryboard *sb = [UIStoryboard storyboardWithName:splashScreen bundle:nil];
        UIViewController *vc = [sb instantiateViewControllerWithIdentifier:splashScreen];
        
        loadingView = vc.view;//[[[NSBundle mainBundle] loadNibNamed:splashScreen owner:self options:nil] objectAtIndex:0];
        CGRect frame = rootView.frame;
        frame.origin = CGPointMake(0, 0);
        loadingView.frame = frame;
    }
    waiting = false;
    
    [rootView addSubview:loadingView];
}

Screenshot 2020-08-31 at 10 27 58 AM

AlishahSolanki avatar Aug 31 '20 05:08 AlishahSolanki

@AlishahSolanki This is the solution when using a storyboard.

Didn't see a PR so ... https://github.com/crazycodeboy/react-native-splash-screen/pull/502

UPDATE - i'm getting black screen flash immediately prior to the splash screen showing up. Only happens on device, not simulator. Only on iOS. Android working ok.

ajp8164 avatar Oct 07 '20 21:10 ajp8164

@tronginc @rickgrundy @metion @massoprod

The issue is, Xcode project is now updated in 0.63 with UIView nib to UIViewController in LaunchScreen.storyboard which means the function in native has to update and change view loading from nib to view controller... Easy solution replace function showSplash with below given fixed code in file RNSplashScreen.m and set storyboard id see attachment below Now it won't crash :)

+ (void)showSplash:(NSString*)splashScreen inRootView:(UIView*)rootView {
    if (!loadingView) {
        UIStoryboard *sb = [UIStoryboard storyboardWithName:splashScreen bundle:nil];
        UIViewController *vc = [sb instantiateViewControllerWithIdentifier:splashScreen];
        
        loadingView = vc.view;//[[[NSBundle mainBundle] loadNibNamed:splashScreen owner:self options:nil] objectAtIndex:0];
        CGRect frame = rootView.frame;
        frame.origin = CGPointMake(0, 0);
        loadingView.frame = frame;
    }
    waiting = false;
    
    [rootView addSubview:loadingView];
}

Screenshot 2020-08-31 at 10 27 58 AM

How do I set storyboard id? No idea where this screenshot is from

ThinkSalat avatar Jan 26 '21 18:01 ThinkSalat

@tronginc @rickgrundy @metion @massoprod The issue is, Xcode project is now updated in 0.63 with UIView nib to UIViewController in LaunchScreen.storyboard which means the function in native has to update and change view loading from nib to view controller... Easy solution replace function showSplash with below given fixed code in file RNSplashScreen.m and set storyboard id see attachment below Now it won't crash :)

+ (void)showSplash:(NSString*)splashScreen inRootView:(UIView*)rootView {
    if (!loadingView) {
        UIStoryboard *sb = [UIStoryboard storyboardWithName:splashScreen bundle:nil];
        UIViewController *vc = [sb instantiateViewControllerWithIdentifier:splashScreen];
        
        loadingView = vc.view;//[[[NSBundle mainBundle] loadNibNamed:splashScreen owner:self options:nil] objectAtIndex:0];
        CGRect frame = rootView.frame;
        frame.origin = CGPointMake(0, 0);
        loadingView.frame = frame;
    }
    waiting = false;
    
    [rootView addSubview:loadingView];
}

Screenshot 2020-08-31 at 10 27 58 AM

How do I set storyboard id? No idea where this screenshot is from

image

You can view it in your Inspectors pane. Then it will be under Show the Identity Inspector tab

akifabubakar avatar Jan 29 '21 12:01 akifabubakar

I was in the same situation as @rickgrundy with switching from LaunchScreen.xib to LaunchScreen.storyboard. Was seeing the same "Could not load NIB" error and the app crashing when SplashScreen.hide() was called.

@rickgrundy's fix worked. Thanks!

Rehubbard avatar Feb 24 '21 19:02 Rehubbard

@tronginc @rickgrundy @metion @massoprod The issue is, Xcode project is now updated in 0.63 with UIView nib to UIViewController in LaunchScreen.storyboard which means the function in native has to update and change view loading from nib to view controller... Easy solution replace function showSplash with below given fixed code in file RNSplashScreen.m and set storyboard id see attachment below Now it won't crash :)

+ (void)showSplash:(NSString*)splashScreen inRootView:(UIView*)rootView {
    if (!loadingView) {
        UIStoryboard *sb = [UIStoryboard storyboardWithName:splashScreen bundle:nil];
        UIViewController *vc = [sb instantiateViewControllerWithIdentifier:splashScreen];
        
        loadingView = vc.view;//[[[NSBundle mainBundle] loadNibNamed:splashScreen owner:self options:nil] objectAtIndex:0];
        CGRect frame = rootView.frame;
        frame.origin = CGPointMake(0, 0);
        loadingView.frame = frame;
    }
    waiting = false;
    
    [rootView addSubview:loadingView];
}

Screenshot 2020-08-31 at 10 27 58 AM

How do I set storyboard id? No idea where this screenshot is from

For anyone else as confused as I was by these vague instructions, open your LaunchScreen.storyboard and then follow the steps below.

Screen Shot 2021-05-13 at 13 39 02

aforty avatar May 13 '21 17:05 aforty

@tronginc @rickgrundy @metion @massoprod

The issue is, Xcode project is now updated in 0.63 with UIView nib to UIViewController in LaunchScreen.storyboard which means the function in native has to update and change view loading from nib to view controller... Easy solution replace function showSplash with below given fixed code in file RNSplashScreen.m and set storyboard id see attachment below Now it won't crash :)

+ (void)showSplash:(NSString*)splashScreen inRootView:(UIView*)rootView {
    if (!loadingView) {
        UIStoryboard *sb = [UIStoryboard storyboardWithName:splashScreen bundle:nil];
        UIViewController *vc = [sb instantiateViewControllerWithIdentifier:splashScreen];
        
        loadingView = vc.view;//[[[NSBundle mainBundle] loadNibNamed:splashScreen owner:self options:nil] objectAtIndex:0];
        CGRect frame = rootView.frame;
        frame.origin = CGPointMake(0, 0);
        loadingView.frame = frame;
    }
    waiting = false;
    
    [rootView addSubview:loadingView];
}

Screenshot 2020-08-31 at 10 27 58 AM

This worked on React 66. Thanks @AlishahSolanki !

zacdemi avatar Jan 11 '22 18:01 zacdemi

Any chance we can get this fix for this merged?

mcmillion avatar Feb 15 '22 22:02 mcmillion