M1 Mac下Expo SDK41 monorepo项目EAS构建Android/iOS失败求助
前置全局配置
- 首先确认你的EAS构建镜像指定了SDK41的兼容版本,SDK41的EAS构建必须用
ubuntu-18.04-android-30-ndk-r19c(Android)和macos-11-xcode-12.5(iOS)的镜像,在eas.json的build配置里加"image"字段指定即可。 - 先清理本地所有子包和根目录的
node_modules,用yarn install --force重装依赖,M1环境下请在Rosetta模式的终端下执行安装命令。
Android端问题解决方案
- gradle脚本不存在问题
不管是否开启symlinks,直接在项目根目录的android/build.gradle里硬编码gradle脚本的动态寻址路径,替换原有的相对路径引用:
把原来的apply from: "../../node_modules/expo-updates/scripts/create-manifest-android.gradle"替换为:
def expoUpdatesScriptPath = new File(["node", "--print", "require.resolve('expo-updates/package.json')"].execute(null, rootDir).text.trim(), "../scripts/create-manifest-android.gradle"); apply from: expoUpdatesScriptPath
expo-constants的gradle脚本也用同样的逻辑替换寻址路径即可。
2. compileSdkVersion未指定问题
在android/build.gradle的ext块里强制指定SDK41对应的编译版本:
ext { buildToolsVersion = "30.0.3" minSdkVersion = 21 compileSdkVersion = 30 targetSdkVersion = 30 }
iOS端问题解决方案
- UMFontInterface规范找不到问题
在expo-yarn-workspaces的symlinks列表里必须保留所有@unimodules开头的包,以及expo-updates、expo-constants两个包,不要移除symlinks配置。同时在ios/Podfile的顶部添加一行配置:
ENV['EXPO_USE_SOURCE'] = '1'
强制pod install时从源码拉取unimodule相关依赖,避免预编译缓存寻址异常。
2. PBXResourcesBuildPhase UUID警告和头文件找不到问题
先执行npx pod-install --clean清理原有Pod缓存,再在Podfile的post_install块里添加以下配置修复问题:
post_install do |installer| installer.pods_project.targets.each do |target| target.build_configurations.each do |config| # 修复EXUpdates头文件寻址 if target.name == 'EXUpdates' config.build_settings['HEADER_SEARCH_PATHS'] ||= ['$(inherited)', '"${PODS_ROOT}/Headers/Public/React-Core"'] end # 适配M1构建,禁用arm64模拟器架构 config.build_settings['EXCLUDED_ARCHS[sdk=iphonesimulator*]'] = 'arm64' end end # 修复PBX UUID警告 installer.pods_project.resources_build_phase.uuid = 'PBXResourcesBuildPhase' end
monorepo专属额外配置
- 在eas.json的build配置里添加
"experimental": { "disableNodeModulesBundler": true },禁用EAS默认的node_modules打包逻辑,避免软链被截断。 - 在app.json的expo块里添加
"nodeModulesPath": "../node_modules",指定依赖根路径适配monorepo目录结构。
内容的提问来源于stack exchange,提问作者E.D
相关产品推荐
相关产品推荐

