solved react-native error: SDK iphoneos cannot be located

While initializing the project, react native has the following error.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
patching file config.sub
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 arm64 -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/lxz/Library/Caches/CocoaPods/Pods/External/glog/2263bd123499e5b93b5efe24871be317-04b94/missing: Unknown `--is-lightweight' option
Try `/Users/lxz/Library/Caches/CocoaPods/Pods/External/glog/2263bd123499e5b93b5efe24871be317-04b94/missing --help' for more information
configure: WARNING: 'missing' script is too old or missing
configure: error: in `/Users/lxz/Library/Caches/CocoaPods/Pods/External/glog/2263bd123499e5b93b5efe24871be317-04b94':
configure: error: C compiler cannot create executables
See `config.log' for more details
✖ Installing CocoaPods dependencies (this may take a few minutes)
error Looks like your iOS environment is not properly set. Please go to https://reactnative.dev/docs/environment-setup?os=macos&platform=android and follow the React Native CLI QuickStart guide for macOS and iOS.
info Run CLI with --verbose flag for more details.

Notice in the error that /Library/Developer/CommandLineTools/ is being used, which should use the path of xcode.

works for me:

1
sudo xcode-select --switch /Applications/Xcode.app

switch to project directory.

1
cd ios && npx pod install && cd .. && react-native run-ios

solved react-native error: SDK iphoneos cannot be located
https://blog.justforlxz.com/2023/06/29/solved-react-native-error-SDK-iphoneos-cannot-be-located/
作者
小竹
发布于
2023年6月29日
许可协议