Help us understand the problem. What is going on with this article?

React Native Fatal error: "config.h" file not found

More than 1 year has passed since last update.

概要

react-nativeの開発をしている際、ビルドが通らなくなったときのメモ。
おそらく他の解決策、これで解決しないケースもあるが参考になれば。

環境

  1. XCode 10.0
  2. nodejs 8.9.4
  3. npm 5.6.0
  4. yarn 1.3.2
  5. react-native 0.52.0
  6. react-native-cli 2.0.1

内容

発生したエラー1

シンプルにreact-native run-iosをした際、下記のエラーが発生しました。一部項目はマスクしています。

❌  /Users/xxxx/node_modules/react-native/third-party/glog-0.3.4/src/base/mutex.h:105:10: 'config.h' file not found
#include "config.h"           // to figure out pthreads support
       ^
▸ Compiling vlog_is_on.cc

❌  /Users/xxxx/node_modules/react-native/third-party/glog-0.3.4/src/base/mutex.h:105:10: 'config.h' file not found
#include "config.h"           // to figure out pthreads support
         ^~~~~~~~~~
▸ Compiling utilities.cc

❌  /Users/xxxx/node_modules/react-native/third-party/glog-0.3.4/src/base/mutex.h:105:10: 'config.h' file not found
#include "config.h"           // to figure out pthreads support
         ^~~~~~~~~~
▸ Compiling symbolize.cc

❌  /Users/xxxx/node_modules/react-native/third-party/glog-0.3.4/src/base/mutex.h:105:10: 'config.h' file not found
#include "config.h"           // to figure out pthreads support
         ^~~~~~~~~~
** BUILD FAILED **
・・・
Installing build/Build/Products/Debug-iphonesimulator/xxx.app
An error was encountered processing the command (domain=NSPOSIXErrorDomain, code=22):
Failed to install the requested application
The bundle identifier of the application could not be determined.
Ensure that the application's Info.plist contains a value for CFBundleIdentifier.
Print: Entry, ":CFBundleIdentifier", Does Not Exist

Command failed: /usr/libexec/PlistBuddy -c Print:CFBundleIdentifier build/Build/Products/Debug-iphonesimulator/xxx.app/Info.plist
Print: Entry, ":CFBundleIdentifier", Does Not Exist

make: *** [run] Error 1

Info.plistはいじっていない。というかむしろXcode側の設定などいじっていないにもかかわらず上記事象が発生した。モジュールが壊れたのだろうか?

処置1

GitHubにIssueがあがっていたのでこれを参考にした。モジュールの再設定を行う様子。

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

エラー内容2

処置1で完了したかと思って、再度ビルドを実行すると今度は下記のエラーが発生した。Websocketライブラリが壊れたのか、存在しないと。

 error: Build input file cannot be found: '/Users/xxx/node_modules/react-native/Libraries/WebSocket/libfishhook.a'

処置2

同じく、別のIssueを参考にした。PRが取り込まれていたので新しくライブラリモジュールを取得しても問題ないが、ライブラリの置き換えのみで対処。

$ cp ./ios/build/Build/Products/Debug-iphonesimulator/libfishhook.a
./node_modules/react-native/Libraries/WebSocket/ 

無事、ビルド完了!

下記の通り、無事ビルドが完了し、シミュレータがあがりました。

$ react-native run-ios
Scanning folders for symlinks in /xxx/node_modules (14ms)
Found Xcode project xxx.xcodeproj
Launching iPhone 8 (iOS 12.0)...
Building using "xcodebuild -project xxx.xcodeproj -configuration Debug -scheme xxx -destination id=xxx -derivedDataPath build"
▸ Running script 'Install Third Party'
▸ Running script 'Start Packager'
▸ Running script 'Include RCTJSCProfiler'
▸ Compiling RCTHTTPRequestHandler.mm
▸ Building library libRCTNetwork.a
▸ Analyzing RCTHTTPRequestHandler.m
▸ Linking xxx
▸ Processing Info.plist
▸ Running script 'Bundle React Native code and images'
▸ Generating 'xxx.app.dSYM'
▸ Running script 'Run Script'
▸ Processing Info.plist
▸ Linking xxxTests
▸ Generating 'xxx.xctest.dSYM'
▸ Build Succeeded

まとめ

react-nativeの記事は日本語のものは少ないけど、英語版はかなり多いし、GithubのIssueに上がっていることは多いです。まずは検索してみると困っている人を見つけることができて、だいたい解決しますw

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away