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

M1芯片Mac无法安装Pod(除Alamofire外)的问题求助

解决方案

1. 修复Podfile语法错误

你的Podfile中pod 'SDWebImage 缺少闭合单引号,这会导致CocoaPods解析失败,修正为:

pod 'SDWebImage'

2. 为Target指定平台

错误提示明确要求为AppTests target指定平台,你可以在Podfile全局指定平台,或为每个target单独配置。以下是完整的修正后Podfile示例:

# 全局指定iOS平台版本,所有target默认继承该配置
platform :ios, '11.0'

target 'AppTest' do
  use_frameworks! # Swift项目或需要动态库支持时添加,OC项目可省略

  pod 'AFNetworking', '~> 2.0'
  pod 'SVProgressHUD'
  pod 'Reachability'
  pod 'UITableView+FDTemplateLayoutCell'
  pod 'SCLAlertView-Objective-C'
  pod 'CRToast', '~> 0.0.7'
  pod 'GLCalendarView', '~> 1.0.0'
  pod 'SDWebImage'
end

target 'AppTests' do
  inherit! :search_paths # 继承主target的Pod搜索路径,避免重复安装依赖
  # 测试target需单独依赖的Pod可在此添加
end

3. M1芯片额外适配操作

由于你使用的是M1芯片Mac,部分老旧Pod可能不支持arm64架构,可尝试以下操作:

  • 右键终端应用,选择「显示简介」,勾选「使用Rosetta打开」,重新打开终端执行pod install
  • 若仍有架构兼容问题,可在Podfile末尾添加如下配置:
post_install do |installer|
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      config.build_settings['ARCHS[sdk=iphonesimulator*]'] = 'x86_64'
    end
  end
end

执行步骤

  1. 保存修正后的Podfile
  2. 删除项目目录下的Podfile.lock文件和Pods文件夹
  3. 执行pod deintegrate清理旧的Pod集成残留
  4. 执行pod install重新安装所有Pod依赖

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.10 00:55:18