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
执行步骤
- 保存修正后的Podfile
- 删除项目目录下的
Podfile.lock文件和Pods文件夹 - 执行
pod deintegrate清理旧的Pod集成残留 - 执行
pod install重新安装所有Pod依赖
内容的提问来源于stack exchange,提问作者HiteshGs
相关产品推荐
相关产品推荐

