React Native中运行pod install报错xcrun: error: SDK “iphoneos“ cannot be located

报错信息

简要报错信息

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’
checking for a BSD-compatible install… /usr/bin/install -c

完整报错信息

-> Installing Flipper-Glog (0.3.6)
 > Git download
 > Git download
     $ /usr/bin/git clone https://github.com/google/glog.git
     /var/folders/48/x1pjkrm51bx6003fs43qhfc00000gn/T/d20210424-48994-8hl2lz
     --template= --single-branch --depth 1 --branch v0.3.5
     Cloning into '/var/folders/48/x1pjkrm51bx6003fs43qhfc00000gn/T/d20210424-48994-8hl2lz'...
     Note: switching to 'a6a166db069520dbbd653c97c2e5b12e08a8bb26'.

     You are in 'detached HEAD' state. You can look around, make experimental
     changes and commit them, and you can discard any commits you make in this
     state without impacting any branches by switching back to a branch.

     If you want to create a new branch to retain commits you create, you may
     do so (now or later) by using -c with the switch command. Example:

       git switch -c <new-branch-name>

     Or undo this operation with:

       git switch -

     Turn off this advice by setting config variable advice.detachedHead to false

 > Running prepare command
   $ /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.  set -e
   PLATFORM_NAME="${PLATFORM_NAME:-iphoneos}" CURRENT_ARCH="${CURRENT_ARCH}"  if
   [ -z "$CURRENT_ARCH" ] || [ "$CURRENT_ARCH" == "undefined_arch" ]; then     #
   Xcode 10 beta sets CURRENT_ARCH to "undefined_arch", this leads to incorrect
   linker arg.     # it's better to rely on platform name as fallback because
   architecture differs between simulator and device      if [[ "$PLATFORM_NAME"
   == *"simulator"* ]]; then         CURRENT_ARCH="x86_64"     else
   CURRENT_ARCH="armv7"     fi fi  export CC="$(xcrun -find -sdk $PLATFORM_NAME
   cc) -arch $CURRENT_ARCH -isysroot $(xcrun -sdk $PLATFORM_NAME
   --show-sdk-path)" export CXX="$CC"  # Remove automake symlink if it exists if
   [ -h "test-driver" ]; then     rm test-driver fi  ./configure --host
   arm-apple-darwin  # Fix build for tvOS cat << EOF >> src/config.h /* Add in
   so we have Apple Target Conditionals */ #ifdef __APPLE__ #include
   <TargetConditionals.h> #include <Availability.h> #endif /* Special
   configuration for AppleTVOS */ #if TARGET_OS_TV #undef HAVE_SYSCALL_H #undef
   HAVE_SYS_SYSCALL_H #undef OS_MACOSX #endif /* Special configuration for
   ucontext */ #undef HAVE_UCONTEXT_H #undef PC_FROM_UCONTEXT #if
   defined(__x86_64__) #define PC_FROM_UCONTEXT uc_mcontext->__ss.__rip #elif
   defined(__i386__) #define PC_FROM_UCONTEXT uc_mcontext->__ss.__eip #endif EOF
   # 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/"
   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'
   checking for a BSD-compatible install... /usr/bin/install -c
   checking whether build environment is sane... yes
   /Users/itkey/Library/Caches/CocoaPods/Pods/Release/Flipper-Glog/0.3.6-1dfd6/missing: Unknown `--is-lightweight' option
   Try `/Users/itkey/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
   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
   configure: error: in `/Users/itkey/Library/Caches/CocoaPods/Pods/Release/Flipper-Glog/0.3.6-1dfd6':
   configure: error: C compiler cannot create executables
   See `config.log' for more details
[!] /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.

set -e

PLATFORM_NAME="${PLATFORM_NAME:-iphoneos}"
CURRENT_ARCH="${CURRENT_ARCH}"

if [ -z "$CURRENT_ARCH" ] || [ "$CURRENT_ARCH" == "undefined_arch" ]; then
    # Xcode 10 beta sets CURRENT_ARCH to "undefined_arch", this leads to incorrect linker arg.
    # it's better to rely on platform name as fallback because architecture differs between simulator and device

    if [[ "$PLATFORM_NAME" == *"simulator"* ]]; then
        CURRENT_ARCH="x86_64"
    else
        CURRENT_ARCH="armv7"
    fi
fi

export CC="$(xcrun -find -sdk $PLATFORM_NAME cc) -arch $CURRENT_ARCH -isysroot $(xcrun -sdk $PLATFORM_NAME --show-sdk-path)"
export CXX="$CC"

# Remove automake symlink if it exists
if [ -h "test-driver" ]; then
    rm test-driver
fi

./configure --host arm-apple-darwin

# Fix build for tvOS
cat << EOF >> src/config.h
/* Add in so we have Apple Target Conditionals */
#ifdef __APPLE__
#include <TargetConditionals.h>
#include <Availability.h>
#endif
/* Special configuration for AppleTVOS */
#if TARGET_OS_TV
#undef HAVE_SYSCALL_H
#undef HAVE_SYS_SYSCALL_H
#undef OS_MACOSX
#endif
/* Special configuration for ucontext */
#undef HAVE_UCONTEXT_H
#undef PC_FROM_UCONTEXT
#if defined(__x86_64__)
#define PC_FROM_UCONTEXT uc_mcontext->__ss.__rip
#elif defined(__i386__)
#define PC_FROM_UCONTEXT uc_mcontext->__ss.__eip
#endif
EOF

# 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/itkey/Library/Caches/CocoaPods/Pods/Release/Flipper-Glog/0.3.6-1dfd6/missing: Unknown `--is-lightweight' option
Try `/Users/itkey/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/itkey/Library/Caches/CocoaPods/Pods/Release/Flipper-Glog/0.3.6-1dfd6':
configure: error: C compiler cannot create executables
See `config.log' for more details


/usr/local/Cellar/cocoapods/1.10.1_1/libexec/gems/cocoapods-1.10.1/lib/cocoapods/executable.rb:73:in `execute_command'
/usr/local/Cellar/cocoapods/1.10.1_1/libexec/gems/cocoapods-1.10.1/lib/cocoapods/executable.rb:27:in `block in executable'
/usr/local/Cellar/cocoapods/1.10.1_1/libexec/gems/cocoapods-1.10.1/lib/cocoapods/installer/pod_source_preparer.rb:66:in `block (2 levels) in run_prepare_command'
/usr/local/Cellar/cocoapods/1.10.1_1/libexec/gems/cocoapods-1.10.1/lib/cocoapods/installer/pod_source_preparer.rb:60:in `chdir'
/usr/local/Cellar/cocoapods/1.10.1_1/libexec/gems/cocoapods-1.10.1/lib/cocoapods/installer/pod_source_preparer.rb:60:in `block in run_prepare_command'
/usr/local/Cellar/cocoapods/1.10.1_1/libexec/gems/cocoapods-1.10.1/lib/cocoapods/user_interface.rb:64:in `section'
/usr/local/Cellar/cocoapods/1.10.1_1/libexec/gems/cocoapods-1.10.1/lib/cocoapods/installer/pod_source_preparer.rb:59:in `run_prepare_command'
/usr/local/Cellar/cocoapods/1.10.1_1/libexec/gems/cocoapods-1.10.1/lib/cocoapods/installer/pod_source_preparer.rb:37:in `prepare!'
/usr/local/Cellar/cocoapods/1.10.1_1/libexec/gems/cocoapods-1.10.1/lib/cocoapods/downloader/cache.rb:202:in `copy_and_clean'
/usr/local/Cellar/cocoapods/1.10.1_1/libexec/gems/cocoapods-1.10.1/lib/cocoapods/downloader/cache.rb:159:in `block (2 levels) in uncached_pod'
/usr/local/Cellar/cocoapods/1.10.1_1/libexec/gems/cocoapods-1.10.1/lib/cocoapods/downloader/cache.rb:157:in `each'
/usr/local/Cellar/cocoapods/1.10.1_1/libexec/gems/cocoapods-1.10.1/lib/cocoapods/downloader/cache.rb:157:in `block in uncached_pod'
/usr/local/Cellar/cocoapods/1.10.1_1/libexec/gems/cocoapods-1.10.1/lib/cocoapods/downloader/cache.rb:181:in `in_tmpdir'
/usr/local/Cellar/cocoapods/1.10.1_1/libexec/gems/cocoapods-1.10.1/lib/cocoapods/downloader/cache.rb:153:in `uncached_pod'
/usr/local/Cellar/cocoapods/1.10.1_1/libexec/gems/cocoapods-1.10.1/lib/cocoapods/downloader/cache.rb:33:in `download_pod'
/usr/local/Cellar/cocoapods/1.10.1_1/libexec/gems/cocoapods-1.10.1/lib/cocoapods/downloader.rb:42:in `download'
/usr/local/Cellar/cocoapods/1.10.1_1/libexec/gems/cocoapods-1.10.1/lib/cocoapods/installer/pod_source_installer.rb:118:in `download_source'
/usr/local/Cellar/cocoapods/1.10.1_1/libexec/gems/cocoapods-1.10.1/lib/cocoapods/installer/pod_source_installer.rb:69:in `install!'
/usr/local/Cellar/cocoapods/1.10.1_1/libexec/gems/cocoapods-1.10.1/lib/cocoapods/installer.rb:561:in `install_source_of_pod'
/usr/local/Cellar/cocoapods/1.10.1_1/libexec/gems/cocoapods-1.10.1/lib/cocoapods/installer.rb:512:in `block (2 levels) in install_pod_sources'
/usr/local/Cellar/cocoapods/1.10.1_1/libexec/gems/cocoapods-1.10.1/lib/cocoapods/user_interface.rb:86:in `titled_section'
/usr/local/Cellar/cocoapods/1.10.1_1/libexec/gems/cocoapods-1.10.1/lib/cocoapods/installer.rb:511:in `block in install_pod_sources'
/usr/local/Cellar/cocoapods/1.10.1_1/libexec/gems/cocoapods-1.10.1/lib/cocoapods/installer.rb:494:in `each'
/usr/local/Cellar/cocoapods/1.10.1_1/libexec/gems/cocoapods-1.10.1/lib/cocoapods/installer.rb:494:in `install_pod_sources'
/usr/local/Cellar/cocoapods/1.10.1_1/libexec/gems/cocoapods-1.10.1/lib/cocoapods/installer.rb:253:in `block in download_dependencies'
/usr/local/Cellar/cocoapods/1.10.1_1/libexec/gems/cocoapods-1.10.1/lib/cocoapods/user_interface.rb:64:in `section'
/usr/local/Cellar/cocoapods/1.10.1_1/libexec/gems/cocoapods-1.10.1/lib/cocoapods/installer.rb:252:in `download_dependencies'
/usr/local/Cellar/cocoapods/1.10.1_1/libexec/gems/cocoapods-1.10.1/lib/cocoapods/installer.rb:161:in `install!'
/usr/local/Cellar/cocoapods/1.10.1_1/libexec/gems/cocoapods-1.10.1/lib/cocoapods/command/install.rb:52:in `run'
/Library/Ruby/Gems/2.6.0/gems/claide-1.0.3/lib/claide/command.rb:334:in `run'
/usr/local/Cellar/cocoapods/1.10.1_1/libexec/gems/cocoapods-1.10.1/lib/cocoapods/command.rb:52:in `run'
/usr/local/Cellar/cocoapods/1.10.1_1/libexec/gems/cocoapods-1.10.1/bin/pod:55:in `<top (required)>'
/usr/local/Cellar/cocoapods/1.10.1_1/libexec/bin/pod:23:in `load'
/usr/local/Cellar/cocoapods/1.10.1_1/libexec/bin/pod:23:in `<main>'
FAIL: 1

解决办法

执行下面命令

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

执行完成以后在运行

pod install --verbose

现在就不报错了。

参考

https://flaviocopes.com/react-native-fix-iphoneos-cannot-be-located/

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值