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

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面板:
    1. 找到Excluded Architectures选项,确认Any iOS Simulator SDK维度下没有添加x86_64、arm64的排除规则
    2. 找到Build Active Architecture Only选项,Debug模式设为Yes,Release模式设为No,避免Debug阶段只编译当前连接真机的架构
  • 架构完整性校验
    编译完成后执行命令检查Alamofire的架构切片是否完整:
    lipo -info Carthage/Build/iOS/Alamofire.framework/Alamofire
    
    正常输出需包含armv7、arm64(真机)、x86_64、arm64-simulator(模拟器)四类架构,如果仍然缺失模拟器切片,在项目根目录新建配置文件carthage.xcconfig,写入:
    VALID_ARCHS = armv7 arm64 x86_64 arm64-simulator
    
    再指定配置文件重新执行编译命令:
    XCODE_XCCONFIG_FILE=./carthage.xcconfig carthage update --platform iOS --no-use-binaries
    
  • 检查依赖引入路径
    进入Build Phases面板,确认Embed Frameworks阶段引入的是Carthage/Build/iOS根目录下的Alamofire.framework,没有误选真机专属的子目录产物。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.29 18:18:38