React Native Fatal error: "config.h" file not found
概要
react-nativeの開発をしている際、ビルドが通らなくなったときのメモ。 おそらく他の解決策、これで解決しないケースもあるが参考になれば。
環境
内容
発生したエラー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