Skip to content

Upgrading to Flagship 4 (React Native 0.59)

Brett Weissbart edited this page Jul 11, 2019 · 7 revisions

Flagship 4 upgrades React Native to version 0.59. This release includes the following features:

  • React Hooks
  • Modernized JavaScriptCore implementation for Android including 64-bit support
  • Update Android builds to use SDK 28 (Pie)
  • Utilize JavaScriptCore framework for iOS devices

Contents

Resources

A Note About Xcode 10.2

Flagship 4 supports XCode 10.2 and it is recommended that you upgrade to this version in order to stay up-to-date with Apple's build chain.

Installing XCode 10.2 will rename all of the simulators on your computer. This may cause issues running iOS through the command line as prior versions of React Native do not support this naming scheme.

If you receive an error similar to "Could not find [simulator name] simulator", there are a couple options:

  • Run your project through XCode by running flagship init, opening the project in XCode, and then clicking the run button

  • Run this command to patch the react-native CLI: sed -i '' 's/startsWith/includes/g' node_modules/react-native/local-cli/runIOS/findMatchingSimulator.js

This feature is resolved in Flagship 4.0 via React Native 0.59.

Dependency Changes

In addition to upgrading your Flagship dependencies to version 4, you should upgrade the following dependencies to the specified version:

  • "react-native": "0.59.10"
  • "react": "16.8.3"

If your project already has any of the following dependencies, they should be updated to the specified versions:

If you receive an error similar to "Undefined is not an object (evaluating 'RNI18n.languages')", you need to manually specify react-native-i18n in your package.json file so it gets linked at the init stage:

  • "react-native-i18n": "2.0.15",

react-native-code-push

If your project implements react-native-code-push, please note that Flagship no longer supports injecting Code Push credentials through the command line. In order to utilize the new way to pass credentials to Code Push, make sure your project is configured as follows:

  1. Update react-native-code-push dependency to "5.6.0"

  2. Verify that your environment configuration is set up as follows:

codepush: {
  appCenterToken: 'XXX',
  ios: {
    appKey: 'XXX',
    deploymentKey: 'XXX'
  },
  android: {
    appKey: 'XXX',
    deploymentKey: 'XXX'
  }
}

Flagship will then copy your credentials into strings.xml (Android) and Info.plist (iOS) where they'll be picked up by RN Code Push.

Module Scripts

Flagship contains an internal set of scripts used to add missing native code for third party libries that do not work propertly with react-native init.

If your project adds additional scripts (these are copied into node_modules/@brandingbrand/flagship/dist/lib/modules), please note that the format for these scripts has changed:

  1. The modules directory has been split into ios and android subdirectories
  2. Each script can export a preLink and/or postLink function which will run before and after react-native link, respectively.

In order to migrate your scripts, you'll need to break them into iOS and Android versions and then have them export preLink or postLink functions instead of ios and android functions.

Android on Travis CI

Travis CI has documented problems with its built-in Android components, especially when dealing with the newer versions of the Android SDK introduced in this version of React Native.

Should you receive an error in your Android tests similar to "no emulators available", we'd recommend using the solution used by .travis.yml in the Flagship repository. The before_install block should stay the same, while the script block should be the steps used to run Android for your application.

Errors & Solutions

Tried to register two views with the same name RCCToolBar

You likely specified a different version of react-native-navigation than used in Flagship. Make sure you have the same version in your package.json: "react-native-navigation": "https://github.com/brandingbrand/react-native-navigation#v1"

Undefined is not an object (evaluating 'RNI18n.languages')

Solution 1: Add react-native-i18n as a dependency to package.json to make sure it gets linked appropriately: "react-native-i18n": "2.0.15"

Solution 2: Make sure you're using the correct version of react-native-codepush (see section above) as older versions may cause react-native link to fail silently

Clone this wiki locally