LoginSignup
0
0

More than 3 years have passed since last update.

ReactNative環境構築でのトラブルシューティング

Last updated at Posted at 2020-01-25

今回は環境構築、シュミレータを実行する際にエラーについて、自分が直面した物をまとめようかと思います。

①"config.h" file not found

react-native run-iosした時にタイトルのようなエラーが発生することがあります。

解決法

モジュールの再設定を行うようです。

$ cd node_modules/react-native/third-party/glog-0.x.x
$ ../../scripts/ios-configure-glog.sh

glogフォルダが見つからない場合がたまにあるかもしれません。

その時は下記コマンドを実行することで作られます。

$ cd node_modules/react-native/scripts/
$ sh ios-install-third-party.sh

②Could not find iPhone X simulator

run-iosでシュミレータがないよとなることがあります。

バージョンを指定すれば、対象の端末で起動しますが、指定しないとiPhone6で起動します。

react-native run-ios --simulator 'iPhone Xs'

なので、別の原因が考えられます。

解決法

findMatchingSimulator.jsの書き換えで解決できます。

./node_modules/react-native/local-cli/runIOS/findMatchingSimulator.js

if (!version.startsWith('iOS') && !version.startsWith('tvOS')) {
    continue;
  }

// 下記に書き換え
if (!version.startsWith('com.apple.CoreSimulator.SimRuntime.iOS') && !version.startsWith('com.apple.CoreSimulator.SimRuntime.tvOS')) {
    continue;
  }

③Can’t find ‘node’ binary to build React Native bundle

実機でビルド時に起こるエラーです。

解決法

nodeのパスを修正すれば直ります。

XcodeのProject ファイル > TARGETS > APP Name > Build Phases > Bundel React Native code and imageを選択して、

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

export NODE_BINARY=$HOME/.nodebrew/current/bin/node
../node_modules/react-native/packager/react-native-xcode.sh

に修正したら、直りました。

ちなみに、nodeのパスは下記コマンドで確認できるようです。

export -p

一般的に遭遇しそうなものを記載しました。

他に出てきたら追記しようと思います。

参照

issue1

issue2

React Native エラー Can’t find ‘node’ binary to build React Native bundle

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0