Expo SDK 49本地iOS构建失败:CocoaPods找不到兼容SocketRocket版本
问题描述
按照Expo SDK 49升级指南将应用升级后,无法通过以下命令本地构建iOS应用:
eas build --profile dev-simulator --platform ios --local --clear-cache
构建因错误终止,但远程构建正常,且能通过expo start --dev-client --ios运行。已尝试删除node_modules并用yarn重装,也安装了Xcode提示的组件,求解决方法。
系统信息
- System Version: macOS 13.4.1 (22F82)
- Kernel Version: Darwin 22.5.0
- CPU: 八核64位arm_blizzard_avalanche
- Clang: 14.0.3 build 1403
- CLT: 14.3.1.0.1.1683849156
- Xcode: 14.3.1
依赖配置
{ ... "packageManager": "yarn@3.4.1", "dependencies": { "@babel/preset-typescript": "^7.22.5", "@config-plugins/react-native-ble-plx": "^6.0.0", "@fortawesome/fontawesome-svg-core": "^6.4.0", "@fortawesome/free-brands-svg-icons": "^6.4.0", "@fortawesome/pro-duotone-svg-icons": "^6.4.0", "@fortawesome/pro-light-svg-icons": "^6.4.0", "@fortawesome/pro-regular-svg-icons": "^6.4.0", "@fortawesome/react-native-fontawesome": "^0.3.0", "@fortawesome/sharp-solid-svg-icons": "^6.4.0", "@react-native-async-storage/async-storage": "1.18.2", "@react-native-community/netinfo": "9.3.10", "@react-native-picker/picker": "2.4.10", "@react-navigation/drawer": "^6.6.3", "@react-navigation/native": "^6.1.7", "@reduxjs/toolkit": "^1.9.5", "amazon-cognito-identity-js": "^6.3.1", "aws-amplify": "^5.3.3", "aws-amplify-react-native": "^7.0.2", "expo": "^49.0.0", "expo-dev-client": "~2.4.4", "expo-file-system": "~15.4.2", "expo-sharing": "~11.5.0", "expo-splash-screen": "~0.20.4", "expo-status-bar": "~1.6.0", "expo-updates": "~0.18.8", "react": "18.2.0", "react-dom": "18.2.0", "react-native": "0.72.1", "react-native-ble-plx": "^2.0.3", "react-native-gesture-handler": "~2.12.0", "react-native-get-random-values": "~1.8.0", "react-native-logs": "^5.0.1", "react-native-reanimated": "~3.3.0", "react-native-safe-area-context": "4.6.3", "react-native-screens": "~3.22.1", "react-native-svg": "13.9.0", "react-native-web": "~0.19.6", "react-redux": "^8.1.1", "uuid": "^9.0.0" }, "devDependencies": { "@babel/core": "^7.22.8", "@babel/plugin-proposal-nullish-coalescing-operator": "^7.18.6", "@babel/plugin-proposal-optional-chaining": "^7.21.0", "@babel/plugin-transform-arrow-functions": "^7.22.5", "@babel/plugin-transform-shorthand-properties": "^7.22.5", "@babel/plugin-transform-template-literals": "^7.22.5", "@redux-devtools/core": "^3.13.1", "@types/jest": "^29.5.2", "@types/react": "~18.0.27", "@types/react-redux": "^7.1.25", "@types/uuid": "^9.0.2", "@typescript-eslint/eslint-plugin": "^5.61.0", "@typescript-eslint/parser": "^5.61.0", "eslint": "^8.44.0", "eslint-plugin-jest": "^27.2.2", "eslint-plugin-react": "^7.32.2", "eslint-plugin-react-hooks": "^4.6.0", "jest": "^29.6.1", "jest-expo": "^49.0.0", "typescript": "^5.1.6" }, ... }
错误日志
[INSTALL_PODS] Framework build type is static library [INSTALL_PODS] [Codegen] Generating ./build/generated/ios/React-Codegen.podspec.json [INSTALL_PODS] Analyzing dependencies [INSTALL_PODS] Fetching podspec for `DoubleConversion` from `../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec` [INSTALL_PODS] [Codegen] Found FBReactNativeSpec [INSTALL_PODS] Fetching podspec for `RCT-Folly` from `../node_modules/react-native/third-party-podspecs/RCT-Folly.podspec` [INSTALL_PODS] [Codegen] Found rncore [INSTALL_PODS] Fetching podspec for `boost` from `../node_modules/react-native/third-party-podspecs/boost.podspec` [INSTALL_PODS] Fetching podspec for `glog` from `../node_modules/react-native/third-party-podspecs/glog.podspec` [INSTALL_PODS] [!] CocoaPods could not find compatible versions for pod "SocketRocket": [INSTALL_PODS] In Podfile: [INSTALL_PODS] React-Core (from `../node_modules/react-native/`) was resolved to 0.72.1, which depends on [INSTALL_PODS] SocketRocket (= 0.6.1) [INSTALL_PODS] None of your spec sources contain a spec satisfying the dependency: `SocketRocket (= 0.6.1)`. [INSTALL_PODS] You have either: [INSTALL_PODS] * out-of-date source repos which you can update with `pod repo update` or with `pod install --repo-update`. [INSTALL_PODS] * mistyped the name or version. [INSTALL_PODS] * not added the source repo that hosts the Podspec to your Podfile. [INSTALL_PODS] [!] `<PBXResourcesBuildPhase UUID=`13F07F8E1...B00A75B9A`>` attempted to initialize an object with an unknown UUID. `14F076057...F822C3CDB` for attribute: `files`. This can be the result of a merge and the unknown UUID is being discarded. [INSTALL_PODS] Error: pod install exited with non-zero code: 31 at ChildProcess.completionListener (/Users/Rax/.npm/_npx/2b827...8729/node_modules/@expo/spawn-async/build/spawnAsync.js:42:23) at Object.onceWrapper (node:events:628:26) at ChildProcess.emit (node:events:513:28) at maybeClose (node:internal/child_process:1091:16) at Socket.<anonymous> (node:internal/child_process:449:11) at Socket.emit (node:events:513:28) at Pipe.<anonymous> (node:net:322:12) ... at spawnAsync (/Users/Rax/.npm/_npx/2b827...8729/node_modules/@expo/spawn-async/build/spawnAsync.js:7:23) at spawn (/Users/Rax/.npm/_npx/2b827...8729/node_modules/@expo/turtle-spawn/dist/index.js:16:47) at installPods (/Users/Rax/.npm/_npx/2b827...8729/node_modules/@expo/build-tools/dist/ios/pod.js:11:38) at /Users/Rax/.npm/_npx/2b827...8729/node_modules/@expo/build-tools/dist/builders/ios.js:68:41) at BuildContext.runBuildPhase (/Users/Rax/.npm/_npx/2b827...8729/node_modules/@expo/build-tools/dist/context.js:86:34) at buildAsync (/Users/Rax/.npm/_npx/2b827...8729/node_modules/@expo/build-tools/dist/builders/ios.js:67:19) at async runBuilderWithHooksAsync (/Users/Rax/.npm/_npx/2b827...8729/node_modules/@expo/build-tools/dist/builders/common.js:12:13) at async Object.iosBuilder (/Users/Rax/.npm/_npx/2b827...8729/node_modules/@expo/build-tools/dist/builders/ios.js:27:16) at async buildIosAsync (/Users/Rax/.npm/_npx/2b827...8729/node_modules/eas-cli-local-build-plugin/dist/ios.js:66:12) at async buildAsync (/Users/Rax/.npm/_npx/2b827...8729/node_modules/eas-cli-local-build-plugin/dist/build.js:55:29) Build failed Unknown error. See logs for more information. npx exited with non-zero code: 1 Error: build command failed.
解决方案
1. 更新CocoaPods仓库
错误提示明确指出可能是仓库过时,先执行:
pod repo update
如果还是不行,在执行构建时加上仓库更新参数:
eas build --profile dev-simulator --platform ios --local --clear-cache --pod-install-flag="--repo-update"
2. 手动指定SocketRocket源
如果更新仓库后仍找不到SocketRocket 0.6.1,可在项目的ios/Podfile顶部添加官方源:
source 'https://github.com/CocoaPods/Specs.git'
保存后重新执行本地构建。
3. 深度清理缓存与依赖
- 删除ios目录下的
Pods文件夹和Podfile.lock文件 - 删除本地CocoaPods缓存目录:
rm -rf ~/.cocoapods/repos - 重新安装项目依赖:
yarn install - 再次尝试本地构建命令
4. 检查并更新CocoaPods版本
确保使用的CocoaPods版本与React Native 0.72.1兼容,推荐1.12.x及以上版本。查看当前版本:
pod --version
版本过低则执行更新:
sudo gem install cocoapods
5. 修复Xcode项目UUID警告
针对错误中的UUID问题,可通过以下步骤修复:
- 打开Xcode项目,选择
File > Project Settings - 点击
Advanced选项,选择Custom > Relative to Workspace,点击Done保存 - 清理项目:
Cmd + Shift + K,再执行Cmd + B重新构建项目
内容的提问来源于stack exchange,提问作者orome
相关产品推荐
相关产品推荐

