You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Expo iOS构建失败求助(SDK 51/React Native 0.74.1)

Expo SDK 51 + React Native 0.74.1 iOS构建失败:Podfile语法错误与包名解析问题

问题详情

使用Expo SDK 51和React Native 0.74.1开发应用,iOS构建持续失败,已尝试以下方法但无效:

  • 删除node_modules并执行yarn install
  • 降级至Expo SDK 50
  • 在AndroidManifest.xml中添加package="com.packageName"

构建日志

Using Expo modules
[Expo] Enabling modular headers for pod ExpoModulesCore
[Expo] Enabling modular headers for pod React-Core
[Expo] Enabling modular headers for pod React-RCTAppDelegate
[Expo] Enabling modular headers for pod expo-dev-menu-interface
[Expo] Enabling modular headers for pod EXManifests
[Expo] Enabling modular headers for pod EXUpdatesInterface
[Expo] Enabling modular headers for pod expo-dev-menu
[Expo] Enabling modular headers for pod React-jsinspector
[Expo] Enabling modular headers for pod RCT-Folly
[Expo] Enabling modular headers for pod glog
[Expo] Enabling modular headers for pod React-RCTFabric
[Expo] Enabling modular headers for pod React-Codegen
[Expo] Enabling modular headers for pod RCTRequired
[Expo] Enabling modular headers for pod RCTTypeSafety
[Expo] Enabling modular headers for pod ReactCommon
[Expo] Enabling modular headers for pod React-NativeModulesApple
[Expo] Enabling modular headers for pod Yoga
[Expo] Enabling modular headers for pod React-Fabric
[Expo] Enabling modular headers for pod React-graphics
[Expo] Enabling modular headers for pod React-utils
[Expo] Enabling modular headers for pod React-featureflags
[Expo] Enabling modular headers for pod React-debug
[Expo] Enabling modular headers for pod React-ImageManager
[Expo] Enabling modular headers for pod React-rendererdebug
[Expo] Enabling modular headers for pod DoubleConversion
[Expo] Enabling modular headers for pod hermes-engine
[Expo] Enabling modular headers for pod expo-dev-launcher
[Expo] Enabling modular headers for pod SDWebImage
[Expo] Enabling modular headers for pod SDWebImageWebPCoder
[Expo] Enabling modular headers for pod SDWebImageAVIFCoder
[Expo] Enabling modular headers for pod SDWebImageSVGCoder
[Expo] Enabling modular headers for pod libavif
error Failed to build the app: No package name found. We couldn't parse the namespace from neither your build.gradle[.kts] file at /Users/expo/workingdir/build/extra-mobile/node_modules/expo-template-bare-minimum/android/build.gradle nor your package in the AndroidManifest at /Users/expo/workingdir/build/extra-mobile/node_modules/expo-template-bare-minimum/android/app/src/main/AndroidManifest.xml.
[!] Invalid `Podfile` file: 783: unexpected token at ''
 #  from /Users/expo/workingdir/build/extra-mobile/ios/Podfile:21
 #  -------------------------------------------
 #  # @generated end react-native-maps
 >    config = use_native_modules!
 #  
 #  -------------------------------------------
Error: Unknown error. See logs of the Install pods build phase for more information.

错误分析

  1. 包名解析错误:日志显示无法解析node_modules/expo-template-bare-minimum中的Android包名,说明项目中可能残留了该模板的无效依赖,或者初始化时的配置未清理完全。
  2. Podfile语法错误:Podfile第21行config = use_native_modules!存在意外token,大概率是react-native-maps的自动生成注释块未正确闭合,导致后续代码语法失效。

解决方案

1. 清理无效模板依赖

  • 打开项目根目录的package.json,查找并移除expo-template-bare-minimum相关依赖项
  • 执行yarn install重新安装依赖
  • 执行npx expo prebuild --clean清理并重新生成原生配置

2. 修复Podfile语法问题

  • 打开ios/Podfile,定位到第21行附近的# @generated end react-native-maps注释,确认注释块无语法错误(如未闭合的注释、乱码字符)
  • 检查config = use_native_modules!这一行的格式,确保无多余空格、引号或特殊字符
  • 若Podfile为自动生成且问题仍存在,可删除ios/Podfile和ios/Podfile.lock,执行npx expo prebuild重新生成Podfile

3. 确认项目包名配置

  • 确保项目自身的android/app/src/main/AndroidManifest.xml(而非node_modules中的模板文件)包含正确的package属性,如package="com.yourappname"
  • 在app.json或app.config.js中配置完整的平台标识符:
    {
      "expo": {
        "ios": {
          "bundleIdentifier": "com.yourappname"
        },
        "android": {
          "package": "com.yourappname"
        }
      }
    }
    

4. 清理构建缓存

  • 执行npx expo start --clear清理Expo缓存
  • 进入iOS目录,执行pod deintegrate && pod install清理Pod依赖并重新安装

内容的提问来源于stack exchange,提问作者islamaf

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.24 07:36:03