React Native iOS打包报错:AmplifyRTNCore.modulemap未找到及架构问题
解决React Native + AWS Amplify Xcode打包报错问题
一、处理AmplifyRTNCore/AmplifyRTNCore.modulemap not found错误
- 验证Podfile配置:确认
pod 'AmplifyRTNCore'已正确添加到Podfile中,执行pod install后检查Pods目录下是否存在该模块 - 彻底清理重建依赖:
- 关闭Xcode
- 删除项目根目录的
Pods文件夹、Podfile.lock文件 - 执行命令:
pod deintegrate && pod install - 打开Xcode后执行
Product > Clean Build Folder(快捷键Cmd+Shift+K)
- 修正Xcode Build Settings:
- 在
Header Search Paths中添加${PODS_ROOT}/AmplifyRTNCore,设置为recursive,同时保留$(inherited) - 若手动指定过
Module Map File,将路径改为${PODS_ROOT}/AmplifyRTNCore/AmplifyRTNCore.modulemap
- 在
二、解决arm64架构下source: unbound variable的PhaseScriptExecution错误
该错误多因shell脚本兼容性或环境变量问题导致:
- 调整脚本解释器:
进入Xcode项目的Build Phases标签,找到[CP-User] Generate app.config for prebuilt Amplify Libraries脚本,将开头的#!/bin/sh改为#!/bin/bash - 替换
source命令:
若脚本中存在source调用,替换为POSIX兼容的.写法,比如将source "$SRCROOT/../node_modules/aws-amplify-react-native/scripts/amplify_config.sh"改为. "$SRCROOT/../node_modules/aws-amplify-react-native/scripts/amplify_config.sh" - 切换默认shell:
在终端执行chsh -s /bin/bash(输入系统密码确认),将默认shell改为bash后重启Xcode - 检查Build Settings中的
Shell Path,确保设置为/bin/bash
额外建议
- 确认React Native与AWS Amplify版本兼容,优先使用官方推荐的版本组合
- 打包时选择
Release模式和正确的Scheme - 若Podfile中使用了
use_frameworks!,尝试改为use_frameworks! :linkage => :static,避免动态库路径异常
内容的提问来源于stack exchange,提问作者ojandali
相关产品推荐
相关产品推荐

