React-native: App stucks on splash screen when build Archive iOS

Created on 18 Jan 2018  路  11Comments  路  Source: facebook/react-native

Is this a bug report?

Yes

Have you read the Contributing Guidelines?

Yes

Environment

Environment:
OS: macOS Sierra 10.12.6
Node: 8.2.1
Yarn: 1.3.2
npm: 5.6.0
Watchman: 4.9.0
Xcode: Xcode 9.2 Build version 9C40b
Android Studio: 3.0 AI-171.4408382

Packages: (wanted => installed)
react: 16.0.0 => 16.0.0
react-native: 0.51.0 => 0.51.0

Actual Behavior

When building my app for Debug or Release, everything works fine, the app launches and loads js.
But when I pack my app for Archive (Release version), it stucks on LaunchScreen.

UPD:
I tried uploading archive to TestFlight and to Crashlytics Beta. Both have same result. App doesn't launch further then LaunchScreen.

AppDelegate.m

/**
 * Copyright (c) 2015-present, Facebook, Inc.
 * All rights reserved.
 *
 * This source code is licensed under the BSD-style license found in the
 * LICENSE file in the root directory of this source tree. An additional grant
 * of patent rights can be found in the PATENTS file in the same directory.
 */

#import "AppDelegate.h"

#import <React/RCTBundleURLProvider.h>
#import <React/RCTRootView.h>
#import <Fabric/Fabric.h>
#import <Crashlytics/Crashlytics.h>

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  NSURL *jsCodeLocation;

  [Fabric with:@[[Crashlytics class]]];

//  jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
  jsCodeLocation = [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];

  RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation
                                                      moduleName:@"App"
                                               initialProperties:nil
                                                   launchOptions:nil];
  rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1];

  self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
  UIViewController *rootViewController = [UIViewController new];
  rootViewController.view = rootView;
  self.window.rootViewController = rootViewController;
  [self.window makeKeyAndVisible];

  UIView* launchScreenView = [[[NSBundle mainBundle] loadNibNamed:@"LaunchScreen" owner:self options:nil] objectAtIndex:0];
  launchScreenView.frame = self.window.bounds;
  rootView.loadingView = launchScreenView;

  return YES;
}

@end 

index.js

import React, {Component} from 'react';
import { AppRegistry } from 'react-native';
import App from './App';

// console.disableYellowBox = true;

AppRegistry.registerComponent('App', () => App);

App.js

import React, {Component} from 'react';
import {StackNavigator, TabNavigator} from 'react-navigation';
import SplashScreen from './src/views/splashScreen';
import LoginView from './src/views/loginView';
import SuppliesView from "./src/views/SuppliesView";
import ProductsView from "./src/views/ProductsView";
import ScanView from "./src/views/ScanView";
import ReadyView from "./src/views/ReadyView";

const Navigator = StackNavigator({
    SuppliesView: {
        screen: SuppliesView
    },
    ProductsView: {
        screen: ProductsView,
    },
    ScanView: {
        screen: ScanView,
    },
    ReadyView: {
        screen: ReadyView
    }
});

const MainNavigator = TabNavigator({
    Main: {
        screen: Navigator,
        navigationOptions: {
            header: null,
        },
    }
});

const MainApp = StackNavigator({
    Splash: {
        screen: SplashScreen,
        navigationOptions: {
            gesturesEnabled: false,
        },
    },
    Login: {
        screen: LoginView,
    },
    Main: {
        screen: MainNavigator,
    }
});

export default class App extends React.Component {
    render() {
        return <MainApp />;
    }
}

package.json

{
    "name": "App",
    "version": "0.0.1",
    "private": true,
    "scripts": {
        "start": "node node_modules/react-native/local-cli/cli.js start",
        "test": "jest"
    },
    "dependencies": {
        "moment": "^2.19.2",
        "moment-timezone": "^0.5.14",
        "numeral": "^2.0.6",
        "react": "16.0.0",
        "react-native": "0.51.0",
        "react-native-blur": "^3.2.2",
        "react-native-camera": "^0.12.0",
        "react-native-fabric": "^0.5.1",
        "react-native-i18n": "^2.0.9",
        "react-native-linear-gradient": "^2.3.0",
        "react-native-navigation": "^1.1.348",
        "react-native-sound": "^0.10.4",
        "react-navigation": "^1.0.0-beta.19",
        "underscore": "^1.8.3",
        "url": "^0.11.0"
    },
    "devDependencies": {
        "babel-jest": "21.2.0",
        "babel-preset-react-native": "4.0.0",
        "jest": "21.2.1",
        "react-test-renderer": "16.0.0"
    },
    "jest": {
        "preset": "react-native"
    }
}

Similar problem #16611 and #14777

Locked

Most helpful comment

Turns out that the problem for me was that CocoaPods was also building react.

The solution was to remove React from the Pods targets in this tab:
captura de pantalla 2018-01-25 a las 21 08 19

Good Luck!

All 11 comments

Exactly the same happening here.

Tried many things. Installing from XCode directly to phone by using the exported ipa after archiving doesn't go past the launch screen.

The main.jsbundle and the assets are present inside the .ipa, the jsCodeLocation is correctly pointing to the bundle.

There are no logs to debug anything, only an ios watchdog timeout. I'm handling all the JS crashes and none are reported, so the problem is with Native code and probably the loading of the bundle (in theory...).

In my case, I'm using cocoaPods and RN 0.51

same problem =(

Turns out that the problem for me was that CocoaPods was also building react.

The solution was to remove React from the Pods targets in this tab:
captura de pantalla 2018-01-25 a las 21 08 19

Good Luck!

@albert-carreras Thanks, it helped!

I bet, React reappears after next pod install or pod update. Is that true?

@Andreyco yes, of course, but as hotfix it works.

@ulyanovn this could help automate the process

post_install do |installer|
  installer.pods_project.targets.each do |target|
    if target.name == "React"
      target.remove_from_project
    end
  end
end

@albert-carreras its working just 1000 thanks !!! but what can have be the incidence of this practice ? and what does it really mean ? my podFile is like this

See http://stackoverflow.com/questions/33395675/cocoapods-file-reference-is-a-member-of-multiple-groups

install! 'cocoapods', :deterministic_uuids => false

target 'homefriend' do
pod 'react-native-smooch', :path => '../node_modules/bamlab-react-native-smooch'
pod 'React', :path => '../node_modules/react-native'
pod 'BVLinearGradient', :path => '../node_modules/react-native-linear-gradient'
pod "Yoga", :path => "../node_modules/react-native/ReactCommon/yoga"
end

thanks

i have tested to run pod install after deleting the React from Pods Target and saw that React back again as Pods Target . that means that i have to remove React from Podfile which can be dangerous for the project perheps . need help about this please

@nadirHomeFriend see my comment above, it removes all react deps from all pods

@Andreyco it works thanks !

Was this page helpful?
0 / 5 - 0 ratings