crazycodeboy / react-native-splash-screen

A splash screen for react-native, hide when application loaded ,it works on iOS and Android.
MIT License
5.59k stars 1.09k forks source link

iOS app crashes after splash screen is initialized version 3.2.0 #488

Open patrikmasiar opened 4 years ago

patrikmasiar commented 4 years ago

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];
...
metion commented 4 years ago

Any solution? Please help

qflagg commented 4 years ago

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.

rickgrundy commented 4 years ago

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
tronginc commented 4 years ago

Same here

AlishahSolanki commented 4 years ago

@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

ajp8164 commented 3 years ago

@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.

ThinkSalat commented 3 years ago

@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

akifabubakar commented 3 years ago

@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

Rehubbard commented 3 years ago

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!

aforty commented 3 years ago

@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

zacdemi commented 2 years ago

@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 !

mcmillion commented 2 years ago

Any chance we can get this fix for this merged?