Expo裸项目EAS iOS构建失败,请求技术排查
问题
我有一个Expo裸项目,EAS iOS构建持续失败,Windows和Mac环境下多次尝试均未成功。项目在Expo Go中运行正常,Android的APK和App Bundle也能正常构建。
package.json 内容
{"main": "node_modules/expo/AppEntry.js", "scripts": {"start": "expo start", "android": "expo start --android", "ios": "expo start --ios", "web": "expo start --web", "eject": "expo eject", "test": "jest", "lint": "eslint . --ext .ts,.tsx --quiet"}, "dependencies": {"@expo/vector-icons": "^13.0.0", "@microsoft/signalr": "^7.0.9", "@react-native-async-storage/async-storage": "1.17.11", "@react-native-community/datetimepicker": "6.7.3", "@react-native-community/masked-view": "0.1.10", "@react-native-community/netinfo": "9.3.7", "@react-native-community/slider": "4.4.2", "@react-navigation/bottom-tabs": "^6.5.7", "@react-navigation/drawer": "5.12.5", "@react-navigation/native": "5.9.4", "@react-navigation/native-stack": "^6.9.15", "@react-navigation/stack": "5.14.5", "@types/react-native-snap-carousel": "^3.8.5", "axios": "^1.4.0", "crypto-js": "^4.1.1", "d3-shape": "^3.2.0", "dayjs": "1.10.5", "expo": "^48.0.0", "expo-app-loading": "2.0.0", "expo-blur": "~12.2.2", "expo-build-properties": "^0.6.0", "expo-checkbox": "~2.3.1", "expo-clipboard": "~4.1.2", "expo-constants": "~14.2.1", "expo-device": "~5.2.1", "expo-document-picker": "~11.2.2", "expo-file-system": "~15.2.2", "expo-haptics": "~12.2.1", "expo-image-picker": "~14.1.1", "expo-linear-gradient": "~12.1.2", "expo-localization": "~14.1.1", "expo-network": "~5.2.1", "expo-notifications": "~0.18.1", "expo-status-bar": "~1.4.4", "formik": "^2.4.2", "i18n-js": "3.8.0", "lottie-colorify": "^0.8.0", "lottie-react-native": "5.1.4", "moment": "^2.30.1", "moment-hijri": "^2.1.2", "native-base": "^3.4.28", "react": "18.2.0", "react-dom": "18.2.0", "react-native": "0.71.14", "react-native-animatable": "^1.3.3", "react-native-chart-kit": "^6.12.0", "react-native-collapsible": "^1.6.1", "react-native-dns-lookup": "^1.0.6", "react-native-gesture-handler": "~2.9.0", "react-native-image-slider-box": "^2.0.7", "react-native-keyboard-aware-scroll-view": "0.9.4", "react-native-modal-datetime-picker": "^15.0.1", "react-native-pager-view": "^6.1.2", "react-native-phone-number-input": "^2.1.0", "react-native-progress": "^5.0.0", "react-native-reanimated": "~2.14.4", "react-native-reanimated-carousel": "^3.5.1", "react-native-render-html": "^6.3.4", "react-native-safe-area-context": "4.5.0", "react-native-screens": "~3.20.0", "react-native-sectioned-multi-select": "^0.10.0", "react-native-snap-carousel": "^3.9.1", "react-native-svg": "13.4.0", "react-native-svg-charts": "^5.4.0", "react-native-tab-view": "^3.5.2", "react-native-table-component": "^1.2.2", "react-native-user-inactivity": "^1.2.0", "react-native-vector-icons": "^10.0.0", "react-native-vpn-status": "^0.1.3", "react-native-web": "~0.18.11", "react-native-webview": "^11.26.0", "rn-pdf-reader-js-improved": "^1.0.0", "util": "^0.12.5", "uuidv4": "^6.2.13", "victory-native": "^36.6.10", "yup": "^1.2.0"}, "devDependencies": {"@babel/core": "^7.20.0", "@react-native-community/eslint-config": "2.0.0", "@types/i18n-js": "3.8.1", "@types/react": "~18.0.27", "@types/react-native-svg-charts": "^5.0.12", "@types/react-native-table-component": "^1.2.4", "@types/react-native-vector-icons": "^6.4.13", "eslint": "7.28.0", "jest-expo": "^48.0.0", "typescript": "^4.9.4"}, "private": true, "jest": {"preset": "jest-expo", "transformIgnorePatterns": ["node_modules/(?!(jest-)?react-native|react-clone-referenced-element|@react-native-community|expo(nent)?|@expo(nent)?/.*|react-navigation|@react-navigation/.*|@unimodules/.*|unimodules|sentry-expo|native-base|@sentry/.*)"]}}
构建失败日志(最后几行)
> ARCHIVE FAILED ** > 1464 > The following build commands failed: > 1465▸ > PhaseScriptExecution [CP-User]\ Generate\ Specs /Users/expo/Library/Developer/Xcode/DerivedData/BlomInvest-bzgpuvoqnyjbencycfehxafsvgtm/Build/Intermediates.noindex/ArchiveIntermediates/BlomInvest/IntermediateBuildFilesPath/Pods.build/Release-iphoneos/FBReactNativeSpec.build/Script-46EB2E0001C790.sh (in target 'FBReactNativeSpec' from project 'Pods') > 1466 > ▸ (1 failure) > 1467 > ARCHIVE FAILED ** > 146814691470 > The following build commands failed: > 1471 > PhaseScriptExecution [CP-User]\ Generate\ Specs /Users/expo/Library/Developer/Xcode/DerivedData/BlomInvest-bzgpuvoqnyjbencycfehxafsvgtm/Build/Intermediates.noindex/ArchiveIntermediates/BlomInvest/IntermediateBuildFilesPath/Pods.build/Release-iphoneos/FBReactNativeSpec.build/Script-46EB2E0001C790.sh (in target 'FBReactNativeSpec' from project 'Pods') > 1472 > ▸ (1 failure) > 1473 > Exit status: 65 > 14741475 > +---------------------------------------+ > 1476 > Build environment | > 1477 > +-------------+-------------------------+ > 1478 > xcode_path | /Applications/Xcode.app | > 1479 > gym_version | 2.217.0 | > 1480 > sdk | iPhoneOS17.2.sdk | > 1481 > +-------------+-------------------------+ > 14821483 > Looks like fastlane ran into a build/archive error with your project > 1484 > It's hard to tell what's causing the error, so we wrote some guides on how > 1485 > to troubleshoot build and signing issues: > 1486 > Before submitting an issue on GitHub, please follow the guide above and make > 1487 > sure your project is set up correctly. > 1488 > fastlane uses `xcodebuild` commands to generate your binary, you can see the > 1489 > the full commands printed out in yellow in the above log. > 1490 > Make sure to inspect the output above, as usually you'll find more error information there > 1491 > Error building the application - see the log above > 1492 > Error: The "Run fastlane" step failed with an unknown error. Refer to "Xcode Logs" below for additional, more detailed logs. > Script has ambiguous dependencies causing it to run on every build. > To fix, go to: Xcode » BlomInvest/BlomInvest » Build Phases » 'Start Packager' > Either: Uncheck "Based on dependency analysis", or select output files to trigger the script > Script has ambiguous dependencies causing it to run on every build. > To fix, go to: Xcode » BlomInvest/BlomInvest » Build Phases » 'Bundle React Native code and images' > Either: Uncheck "Based on dependency analysis", or select output files to trigger the script > Script has ambiguous dependencies causing it to run on every build. > To fix, go to: Xcode » BlomInvest/BlomInvest » Build Phases » '[CP-User] [RNFB] Core Configuration' > Either: Uncheck "Based on dependency analysis", or select output files to trigger the script
排查与解决方案
1. 修复FBReactNativeSpec构建错误
这是本次构建失败的核心问题,可按以下步骤处理:
- 清理构建缓存:运行
eas build --clean触发全新构建,清除之前残留的构建文件与缓存 - 统一导航库版本:项目中混合使用了
@react-navigation的v5和v6版本(如drawer、stack为v5,bottom-tabs、native-stack为v6),版本冲突会导致Spec生成失败,建议将所有导航相关依赖统一升级到v6版本 - 升级适配依赖:将
expo-build-properties升级到Expo 48兼容的最新版本,它可配置Xcode构建参数,避免脚本执行异常
2. 解决脚本依赖模糊问题
针对日志中提示的三个脚本问题,需在Xcode中调整配置:
- 打开项目
ios目录下的.xcworkspace文件 - 依次进入
Build Phases中的三个脚本:Start Packager、Bundle React Native code and images、[CP-User] [RNFB] Core Configuration - 对每个脚本,取消勾选
Based on dependency analysis选项;或指定明确的输出文件(例如Bundle React Native code and images可指定main.jsbundle作为输出)
3. 匹配Xcode与RN版本兼容性
当前构建使用iOS17.2 SDK(对应Xcode 15),但React Native 0.71.14默认适配Xcode 14.3.x版本,版本不兼容会引发构建问题。可通过expo-build-properties指定Xcode版本:
在app.json或app.config.js中添加:
{ "expo": { "plugins": [ [ "expo-build-properties", { "ios": { "xcodeVersion": "14.3.1" } } ] ] } }
4. 检查第三方原生模块配置
确认react-native-dns-lookup、react-native-vpn-status等第三方库的原生配置是否完成:
- 执行
cd ios && pod install确保依赖安装完整 - 核对库的官方文档,确认是否遗漏了Info.plist权限配置或其他原生设置
内容的提问来源于stack exchange,提问作者Abdullah Zafar
相关产品推荐
相关产品推荐

