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

Expo EAS iOS构建报错:createInfoPlistPluginWithPropertyGuard非函数

解决Expo 47 iOS构建错误:TypeError与_internal.projectRoot未定义问题

问题背景

项目已4个月未维护,上次构建在2022年10月。升级Expo从45到47后,执行eas build --profile local --platform ios时遇到两个连续错误:

  • 初始错误:移除app.config.js中的插件块后仍出现TypeError: (0 , _iosPlugins(...).createInfoPlistPluginWithPropertyGuard) is not a function
  • 改用withPlugins配置后,触发Unexpected: Config _internal.projectRoot isn't defined by expo-cli, this is a bug.

已尝试操作

  • 将Expo从45版本升级到47.0.13
  • 移除app.config.js里的plugins数组配置
  • 使用@expo/config-plugins的withPlugins函数包裹项目配置

依赖信息

"expo": "^47.0.13",
"sentry-expo": "~6.0.0",
"expo-community-flipper": "^47.0.2",
"react": "18.1.0",

环境信息

expo-env-info 1.0.5 environment info:
    System:
      OS: macOS 12.6.2
      Shell: 5.8.1 - /bin/zsh
    Binaries:
      Node: 18.14.0 - ~/.nvm/versions/node/v18.14.0/bin/node
      Yarn: 1.22.17 - /usr/local/bin/yarn
      npm: 9.3.1 - ~/.nvm/versions/node/v18.14.0/bin/npm
    SDKs:
      iOS SDK:
        Platforms: DriverKit 22.2, iOS 16.2, macOS 13.1, tvOS 16.1, watchOS 9.1
    IDEs:
      Android Studio: 2021.2 AI-212.5712.43.2112.8609683
      Xcode: 14.2/14C18 - /usr/bin/xcodebuild
    npmPackages:
      expo: ^47.0.13 => 47.0.13
      react: 18.1.0 => 18.1.0
      react-dom: 18.1.0 => 18.1.0
      react-native: 0.70.5 => 0.70.5
      react-native-web: ~0.18.7 => 0.18.12
    Expo Workflow: managed

项目配置(app.config.js)

module.exports = {
  name: 'xxx',
  owner: 'xxx',
  slug: 'xxx',
  version: '1.1.5',
  privacy: 'hidden',
  orientation: 'portrait',
  icon: 'xxx',
  scheme: 'xxx',
  runtimeVersion: 'exposdk:47.0.13',
  userInterfaceStyle: 'automatic',
  jsEngine: 'hermes',
  splash: {
    image: './assets/images/splash.png',
    resizeMode: 'cover',
    backgroundColor: '#ffffff',
  },
  updates: {
    fallbackToCacheTimeout: 0,
    url: `https://u.expo.dev/${expoProjectId}`,
    enabled: process.env.APP_VARIANT !== 'local',
  },
  assetBundlePatterns: ['**/*'],
  plugins: [
    'sentry-expo',
    'expo-community-flipper',
  ],
  ios: {
    supportsTablet: false,
    buildNumber: '1.1.5',
    bundleIdentifier: bundleIdentifierIos,
    config: {
      usesNonExemptEncryption: false,
    },
    infoPlist: {
      NSContactsUsageDescription: 'xxx',
      NSPhotoLibraryUsageDescription: 'xxx',
      NSCameraUsageDescription: 'xxx',
      NSLocationWhenInUseUsageDescription: 'xxx',
      UIBackgroundModes: ['remote-notification'],
    },
  },
  android: {
    package: bundleIdentifierAndroid,
    versionCode: 430000271,
    googleServicesFile,
  },
  extra: {
    APP_VARIANT: process.env.APP_VARIANT || null,
    ...env,
    eas: {
      projectId: expoProjectId,
    },
  },
  hooks: {
    postPublish: [{
      file: 'sentry-expo/upload-sourcemaps',
      config: {
        project: env ? env.SENTRY_PROJECT : null,
        organization: env ? env.SENTRY_ORG : null,
        authToken: env ? env.SENTRY_AUTH_TOKEN : null,
      }
    }],
  }
}

解决方案

1. 清理依赖并重新安装

  • 删除node_modules文件夹
  • 删除package-lock.json或yarn.lock文件
  • 执行npm install(或yarn install)重新安装依赖
  • 清除Expo缓存:npx expo r -c

2. 核对插件版本兼容性

  • Expo 47要求sentry-expo版本≥~6.0.0,当前版本符合,可尝试重新安装插件:npm install sentry-expo@~6.0.0 expo-community-flipper@^47.0.2
  • 确认无跨版本依赖冲突,检查package.json中其他插件是否适配Expo 47

3. 修复配置文件语法与结构

  • 放弃使用withPlugins,Expo 47的managed workflow推荐直接在plugins数组中声明插件
  • 将app.config.js的module.exports改为export default(Expo 47更适配ES模块语法),修改后示例:
export default {
  // 原配置内容保持不变
}

4. 更新EAS CLI

执行npm install -g eas-cli升级到最新版EAS CLI,旧版本可能存在与Expo 47的兼容问题

5. 验证配置变量

确保app.config.js中expoProjectId、bundleIdentifierIos等变量已正确定义,未定义的变量会导致配置解析失败

6. 测试Node.js版本兼容性

当前使用Node.js 18.14.0符合要求,可尝试切换到Node.js 16.x版本测试,排查是否存在版本兼容问题

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.02 01:01:18