Carthage集成Alamofire报错找不到x86_64-apple-ios-simulator目标模块
报错信息
could not find module 'Alamofire' for target 'x86_64-apple-ios-simulator'; found: armv7-apple-ios, arm64-apple-ios, at: /Users/datdinh/Desktop/a/requestTest/Carthage/Build/iOS/Alamofire.framework/Modules/Alamofire.swiftmodule
报错核心是Carthage编译生成的Alamofire框架仅包含armv7、arm64两个iOS真机架构切片,缺失x86_64架构的iOS模拟器对应模块,导致Intel Mac上启动iOS模拟器时无法识别依赖。
修复步骤
- 清理旧编译缓存,强制从源码全架构编译
直接在项目根目录执行命令,跳过预编译二进制包(绝大多数该类问题都是预编译包未打包模拟器架构导致):rm -rf Carthage/Build rm -rf ~/Library/Caches/org.carthage.CarthageKit carthage update --platform iOS --no-use-binaries - 校验项目编译配置
打开项目Xcode工程,进入Build Settings面板:- 找到
Excluded Architectures选项,确认Any iOS Simulator SDK维度下没有添加x86_64、arm64的排除规则 - 找到
Build Active Architecture Only选项,Debug模式设为Yes,Release模式设为No,避免Debug阶段只编译当前连接真机的架构
- 找到
- 架构完整性校验
编译完成后执行命令检查Alamofire的架构切片是否完整:
正常输出需包含armv7、arm64(真机)、x86_64、arm64-simulator(模拟器)四类架构,如果仍然缺失模拟器切片,在项目根目录新建配置文件lipo -info Carthage/Build/iOS/Alamofire.framework/Alamofirecarthage.xcconfig,写入:
再指定配置文件重新执行编译命令:VALID_ARCHS = armv7 arm64 x86_64 arm64-simulatorXCODE_XCCONFIG_FILE=./carthage.xcconfig carthage update --platform iOS --no-use-binaries - 检查依赖引入路径
进入Build Phases面板,确认Embed Frameworks阶段引入的是Carthage/Build/iOS根目录下的Alamofire.framework,没有误选真机专属的子目录产物。
内容的提问来源于stack exchange,提问作者Des Han
相关产品推荐
相关产品推荐

