npx pod 安装错误。正在中止运行并且遇到意外错误

Oğu*_*lay 3 macos npm react-native expo create-react-native-app

当我成功安装 create-react-native-app 且没有出现错误时,出现了此警告,当我输入该警告时,终端给了我一个错误或警告,如下所示:An unexpected error was encountered. Please report it as a bug:

\n

有没有人收到此错误代码或类似的代码?请帮助我解决这个问题。

\n
\xe2\x9a\xa0\xef\xb8\x8f  Before running your app on iOS, make sure you have CocoaPods installed and initialize the project:\n\n  cd travel-app-react-native/ios\n  npx pod-install\n\noguzhanatalay@Oguzhans-Mac Desktop % cd travel-app-react-native \noguzhanatalay@Oguzhans-Mac travel-app-react-native % npx pod-install\nnpx: installed 1 in 6.118s\nScanning for pods...\n1.10.0\n> pod install\nInstalling unimodules:\n expo-constants@9.2.0 from ../node_modules/expo-constants/ios\n expo-error-recovery@1.3.0 from ../node_modules/expo-error-recovery/ios\n expo-file-system@9.2.0 from ../node_modules/expo-file-system/ios\n expo-font@8.3.0 from ../node_modules/expo-font/ios\n expo-image-loader@1.2.0 from ../node_modules/expo-image-loader/ios\n expo-keep-awake@8.3.0 from ../node_modules/expo-keep-awake/ios\n expo-linear-gradient@8.3.1 from ../node_modules/expo-linear-gradient/ios\n expo-location@9.0.1 from ../node_modules/expo-location/ios\n expo-permissions@9.3.0 from ../node_modules/expo-permissions/ios\n expo-splash-screen@0.6.2 from ../node_modules/expo-splash-screen/ios\n expo-sqlite@8.4.0 from ../node_modules/expo-sqlite/ios\n expo-updates@0.3.5 from ../node_modules/expo-updates/ios\n unimodules-app-loader@1.3.0 from ../node_modules/unimodules-app-loader/ios\n unimodules-barcode-scanner-interface@5.3.0 from ../node_modules/unimodules-barcode-scanner-interface/ios\n unimodules-camera-interface@5.3.0 from ../node_modules/unimodules-camera-interface/ios\n unimodules-constants-interface@5.3.0 from ../node_modules/unimodules-constants-interface/ios\n unimodules-core@5.5.1 from ../node_modules/@unimodules/core/ios\n unimodules-face-detector-interface@5.3.0 from ../node_modules/unimodules-face-detector-interface/ios\n unimodules-file-system-interface@5.3.0 from ../node_modules/unimodules-file-system-interface/ios\n unimodules-font-interface@5.3.0 from ../node_modules/unimodules-font-interface/ios\n unimodules-image-loader-interface@5.3.0 from ../node_modules/unimodules-image-loader-interface/ios\n unimodules-permissions-interface@5.3.0 from ../node_modules/unimodules-permissions-interface/ios\n unimodules-react-native-adapter@5.6.0 from ../node_modules/@unimodules/react-native-adapter/ios\n unimodules-sensors-interface@5.3.0 from ../node_modules/unimodules-sensors-interface/ios\n unimodules-task-manager-interface@5.3.0 from ../node_modules/unimodules-task-manager-interface/ios\n\nAuto-linking React Native modules for target `travelappreactnative`: RNGestureHandler, RNReanimated, and RNScreens\nAnalyzing dependencies\nFetching podspec for `DoubleConversion` from `../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec`\nFetching podspec for `Folly` from `../node_modules/react-native/third-party-podspecs/Folly.podspec`\nFetching podspec for `glog` from `../node_modules/react-native/third-party-podspecs/glog.podspec`\nDownloading dependencies\nInstalling CocoaAsyncSocket (7.6.4)\nInstalling CocoaLibEvent (1.0.0)\nInstalling DoubleConversion (1.1.6)\nInstalling EXConstants (9.2.0)\nInstalling EXErrorRecovery (1.3.0)\nInstalling EXFileSystem (9.2.0)\nInstalling EXFont (8.3.0)\nInstalling EXImageLoader (1.2.0)\nInstalling EXKeepAwake (8.3.0)\nInstalling EXLinearGradient (8.3.1)\nInstalling EXLocation (9.0.1)\nInstalling EXPermissions (9.3.0)\nInstalling EXSQLite (8.4.0)\nInstalling EXSplashScreen (0.6.2)\nInstalling EXUpdates (0.3.5)\nInstalling FBLazyVector (0.63.3)\nInstalling FBReactNativeSpec (0.63.3)\nInstalling Flipper (0.54.0)\nInstalling Flipper-DoubleConversion (1.1.7)\nInstalling Flipper-Folly (2.3.0)\nInstalling Flipper-Glog (0.3.6)\n[!] /bin/bash -c \nset -e\n#!/bin/bash\n# Copyright (c) Facebook, Inc. and its affiliates.\n#\n# This source code is licensed under the MIT license found in the\n# LICENSE file in the root directory of this source tree.\n\nset -e\n\nPLATFORM_NAME="${PLATFORM_NAME:-iphoneos}"\nCURRENT_ARCH="${CURRENT_ARCH}"\n\nif [ -z "$CURRENT_ARCH" ] || [ "$CURRENT_ARCH" == "undefined_arch" ]; then\n    # Xcode 10 beta sets CURRENT_ARCH to "undefined_arch", this leads to incorrect linker arg.\n    # it's better to rely on platform name as fallback because architecture differs between simulator and device\n\n    if [[ "$PLATFORM_NAME" == *"simulator"* ]]; then\n        CURRENT_ARCH="x86_64"\n    else\n        CURRENT_ARCH="armv7"\n    fi\nfi\n\nexport CC="$(xcrun -find -sdk $PLATFORM_NAME cc) -arch $CURRENT_ARCH -isysroot $(xcrun -sdk $PLATFORM_NAME --show-sdk-path)"\nexport CXX="$CC"\n\n# Remove automake symlink if it exists\nif [ -h "test-driver" ]; then\n    rm test-driver\nfi\n\n./configure --host arm-apple-darwin\n\n# Fix build for tvOS\ncat << EOF >> src/config.h\n/* Add in so we have Apple Target Conditionals */\n#ifdef __APPLE__\n#include <TargetConditionals.h>\n#include <Availability.h>\n#endif\n/* Special configuration for AppleTVOS */\n#if TARGET_OS_TV\n#undef HAVE_SYSCALL_H\n#undef HAVE_SYS_SYSCALL_H\n#undef OS_MACOSX\n#endif\n/* Special configuration for ucontext */\n#undef HAVE_UCONTEXT_H\n#undef PC_FROM_UCONTEXT\n#if defined(__x86_64__)\n#define PC_FROM_UCONTEXT uc_mcontext->__ss.__rip\n#elif defined(__i386__)\n#define PC_FROM_UCONTEXT uc_mcontext->__ss.__eip\n#endif\nEOF\n\n# Prepare exported header include\nEXPORTED_INCLUDE_DIR="exported/glog"\nmkdir -p exported/glog\ncp -f src/glog/log_severity.h "$EXPORTED_INCLUDE_DIR/"\ncp -f src/glog/logging.h "$EXPORTED_INCLUDE_DIR/"\ncp -f src/glog/raw_logging.h "$EXPORTED_INCLUDE_DIR/"\ncp -f src/glog/stl_logging.h "$EXPORTED_INCLUDE_DIR/"\ncp -f src/glog/vlog_is_on.h "$EXPORTED_INCLUDE_DIR/"\n\nchecking for a BSD-compatible install... /usr/bin/install -c\nchecking whether build environment is sane... yes\nchecking for arm-apple-darwin-strip... no\nchecking for strip... strip\nchecking for a thread-safe mkdir -p... ./install-sh -c -d\nchecking for gawk... no\nchecking for mawk... no\nchecking for nawk... no\nchecking for awk... awk\nchecking whether make sets $(MAKE)... yes\nchecking whether make supports nested variables... yes\nchecking for arm-apple-darwin-gcc... /Library/Developer/CommandLineTools/usr/bin/cc -arch armv7 -isysroot \nchecking whether the C compiler works... no\nxcrun: error: SDK "iphoneos" cannot be located\nxcrun: error: SDK "iphoneos" cannot be located\nxcrun: error: SDK "iphoneos" cannot be located\nxcrun: error: unable to lookup item 'Path' in SDK 'iphoneos'\n/Users/oguzhanatalay/Library/Caches/CocoaPods/Pods/Release/Flipper-Glog/0.3.6-1dfd6/missing: Unknown `--is-lightweight' option\nTry `/Users/oguzhanatalay/Library/Caches/CocoaPods/Pods/Release/Flipper-Glog/0.3.6-1dfd6/missing --help' for more information\nconfigure: WARNING: 'missing' script is too old or missing\nconfigure: error: in `/Users/oguzhanatalay/Library/Caches/CocoaPods/Pods/Release/Flipper-Glog/0.3.6-1dfd6':\nconfigure: error: C compiler cannot create executables\nSee `config.log' for more details\n\n\nAborting run\nAn unexpected error was encountered. Please report it as a bug:\nError\n    at CocoaPodsPackageManager._installAsync (/Users/oguzhanatalay/.npm/_npx/4500/lib/node_modules/pod-install/build/index.js:2:85721)\n    at processTicksAndRejections (internal/process/task_queues.js:97:5)\n
Run Code Online (Sandbox Code Playgroud)\n

ken*_*try 6

我相信错误在于这个错误语句:

xcrun: error: SDK "iphoneos" cannot be located
Run Code Online (Sandbox Code Playgroud)

摘自一个旧问题的 github 线程,尝试以下步骤:

运行这个命令: xcrun -k --sdk iphoneos --show-sdk-path

如果输出是:

xcrun: error: SDK "iphoneos" cannot be located
xcrun: error: SDK "iphoneos" cannot be located
xcrun: error: unable to lookup item 'Path' in SDK 'iphoneos'
Run Code Online (Sandbox Code Playgroud)

然后运行这个:sudo xcode-select --switch /Applications/Xcode.app

然后再次安装pod。