概要
XCode 10でreact-native initで作成したプロジェクトでreact-native run-iosを実行した際、色々と詰まったので、その対処法メモ
実行環境
- XCode 10.0
- React Native 55.4
はじめに
XCodeを最低一度起動しておく
XCodeをダウンロードした直後、またはアップデートした直後である場合、XCode起動時に必要な処理が行われるので、一度実行しておく
出てきたエラーとその対処法
":CFBundleIdentifier", Does Not Exist
最初にreact-native run-iosを起動した時、下記エラーが表示された
Installing build/Build/Products/Debug-iphonesimulator/react-native-test.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/react-native-ble-test.app/Info.plist
Print: Entry, ":CFBundleIdentifier", Does Not Exist
このエラーが出た場合、プロジェクトをXCodeで開いてBuild Locationを設定する必要がある
対処法
-
iosディレクトリに入っている<プロジェクト名>.xcodeprojをXCodeで開く -
Menu > File > Project Settings...を選択 -
Advanced...を選択 -
Customにチェックをして、すぐ横のドロップダウンからRelative to workspaceを選択 -
Doneを選択
*追記: 上記手順後、XCodeを再起動すれば改善されたというコメントを頂きました
fatal error: 'config.h' file not found
再度ビルドを試みた際、config.hが見つからないと表示された
# include "config.h" // to figure out pthreads support
^~~~~~~~~~
対処法
このエラーが出た場合、react-nativeディレクトリの中のglogのconfigureを起動すればconfig.hが生成される
* configureを起動するのはglogフォルダの中である必要がある
** glogの位置はReact-Nativeのバージョン、または実行環境によって異なる場合がある。
*** 追記: glogが見つからない場合、node_modules/react-native/scripts/内にある./ios-install-third-party.shを起動するとthird-partyフォルダが作成され、その中にglogフォルダが作成される
$ cd node_modules/react-native/third-party/glog-0.3.4/
$ ./configure
$ cd ../../../..
この手順の後、再度ビルドを試みる
error: Build input file cannot be found: 'libfishhook.a'
このエラーが出た場合、libfishhook.aファイルを再生成する必要がある。
-
iosディレクトリに入っている<プロジェクト名>.xcodeprojをXCodeで開く - XCodeにて、
LibrariesディレクトリにあるRCTWebSocket.xcodeprojを選択する - 上部メニューにある
Build Phasesを開く -
Link Binary with Librariesを選択 -
libfishhook.aが表示されている場合、選択して、下部に表示されてる-を押して削除する - 下部に表示されてる
+を選択してlibfishhook.aを選択してAdd
場所がわからない場合、この画像を参照