[macOS] react-native run-ios、pod installでエラー

まだコードを書いていない...

stack overflowとqiitaにお世話になりっぱなしね

エラー表示

macOS 10.15.5
XCode 11.6
Node.js v12.18.3
react-native-cli: 2.0.1
react-native: 0.63.2

npm installが無事完了できたので、react-native run-iosしたところ、次のエラーが。

$ react-native run-ios
error Could not find "Podfile.lock" at /xxx/yyy/ios/Podfile.lock. Did you run "pod install" in iOS directory?
info Found Xcode project "yyy.xcodeproj"
xcrun: error: unable to find utility "simctl", not a developer tool or in PATH
error Could not get the simulator list from Xcode. Please open Xcode and try running project directly from there to resolve the remaining issues. Run CLI with --verbose flag for more details.
Error: Command failed: xcrun simctl list --json devices
xcrun: error: unable to find utility "simctl", not a developer tool or in PATHCode language: Bash (bash)

iosディレクトリにcdして、pod installしましたが、podコマンドがないとのこと。

$ cd ios
$ pod install
-bash: pod: command not foundCode language: Bash (bash)

cocoapodをインストールします。

$ sudo gem install -n /usr/local/bin cocoapodsCode language: Bash (bash)

cocoapodのインストールが完了しました。

react-nativeプロジェクトのiosディレクトリで、再度pod installしました。次のエラーが。Installing Flipper-Glog (0.3.6)の次から、赤い文字表示です。

$ pod install
Analyzing dependencies
(省略)

Installing Flipper-DoubleConversion (1.1.7)
Installing Flipper-Folly (2.2.0)
Installing Flipper-Glog (0.3.6)

[!] /bin/bash -c 
set -e
#!/bin/bash
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
(省略)

# Prepare exported header include
EXPORTED_INCLUDE_DIR="exported/glog"
mkdir -p exported/glog
cp -f src/glog/log_severity.h "$EXPORTED_INCLUDE_DIR/"
cp -f src/glog/logging.h "$EXPORTED_INCLUDE_DIR/"
cp -f src/glog/raw_logging.h "$EXPORTED_INCLUDE_DIR/"
cp -f src/glog/stl_logging.h "$EXPORTED_INCLUDE_DIR/"
cp -f src/glog/vlog_is_on.h "$EXPORTED_INCLUDE_DIR/"

checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for arm-apple-darwin-strip... no
checking for strip... strip
checking for a thread-safe mkdir -p... ./install-sh -c -d
checking for gawk... no
checking for mawk... no
checking for nawk... no
checking for awk... awk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking for arm-apple-darwin-gcc... /Library/Developer/CommandLineTools/usr/bin/cc -arch armv7 -isysroot 
checking whether the C compiler works... no
xcrun: error: SDK "iphoneos" cannot be located
xcrun: error: SDK "iphoneos" cannot be located
xcrun: error: SDK "iphoneos" cannot be located
xcrun: error: unable to lookup item 'Path' in SDK 'iphoneos'
/Users/xxx/Library/Caches/CocoaPods/Pods/Release/Flipper-Glog/0.3.6-1dfd6/missing: Unknown `--is-lightweight' option
Try `/Users/xxx/Library/Caches/CocoaPods/Pods/Release/Flipper-Glog/0.3.6-1dfd6/missing --help' for more information
configure: WARNING: 'missing' script is too old or missing
configure: error: in `/Users/xxx/Library/Caches/CocoaPods/Pods/Release/Flipper-Glog/0.3.6-1dfd6':
configure: error: C compiler cannot create executables
See `config.log' for more details

Code language: plaintext (plaintext)

対応方法

Command Line Toolsのパスを/Applications/Xcode.app/Contents/Developer にすると、いいようです。

XCodeインストール後に、自力で Command Line Toolsをインストールすると、Command Line Tools のパスが/Library/Developer/CommandLineTools になってしまう、glog(Fligger-Glog)は、この状態を想定していないらしく、エラーになってしまう、と理解しました。

$ xcode-select -print-path
/Library/Developer/CommandLineTools

$ sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer

$ xcode-select -print-path
/Applications/Xcode.app/Contents/DeveloperCode language: PHP (php)

再度、pod installしたところ、無事完了しました。

react-nativeプロジェクトの直下のディレクトリに戻り、react-native run-iosしました。iOSシミュレータが起動し、アプリが表示されました。

コードを書く前から疲れたよ

まだ何もコードを書いていないけど、ひとまず安心ね

参考記事

`react-native init`後のpod installでglogに関してエラーが出た時の対処 - Qiita
現象あるMac環境で下記のコマンドを実行した時、glogでエラーが発生し進めなくなった。react-native init MyTSProject --template react-native…
タイトルとURLをコピーしました