Skip to content

Updating from an existing project to version 0.18.x

Jamie Birch edited this page Jun 13, 2018 · 2 revisions

These instructions detail how to update from an existing version 0.16.1 project to 0.18.0-alpha.3.

Updating

1: Install new dependencies

First, install the latest react-native-macos, then add the new dependency babel-plugin-module-resolver:

yarn add react-native-macos@latest
yarn add -D babel-plugin-module-resolver

2: Resolve the metro bundler issues

If you don't have one already, make a new file called rn-cli.config.js, and ensure the following text is present, as per ptmt's recommendation:

'use strict';

module.exports = {
  getProvidesModuleNodeModules: () => ['react-native-macos'],
  getPlatforms: () => 'macos',
};

3: Update the react-native-xcode.sh script location

Now you'll need to update the location of the packager script. In Xcode, select your build target from your project settings, then navigate to Build Phases > Bundle React Native code and images, and update the location of the packager script from ../node_modules/react-native-macos/packager/react-native-xcode.sh to the subtly different:

export NODE_BINARY=node
../node_modules/react-native-macos/scripts/react-native-xcode.sh

4: Clean caches

I cleaned my Xcode project at this point for good luck. Final step:

npm start -- --reset-cache

5: Run

Now just run the Xcode project.

Troubleshooting

react-devtools error:

If you experience the dreaded __nw_connection_get_connected_socket_block_invoke Connection has no connected handler log-spamming error, then it sounds like you should keep a copy of react-devtools open:

Global install of react-devtools

yarn global add react-devtools
react-devtools

Local install of react-devtools

Haven't tried this, but it should work like this:

yarn add react-devtools
node_modules/.bin/react-devtools