执行pod install后部分Pods未下载,M1 Mac出现模块找不到错误
解决M1 MacBook上CocoaPods模块未下载的问题
第一步:彻底清理旧Pod文件
先移除可能存在的缓存或损坏文件:
- 删除项目根目录下的
Pods文件夹 - 删除
Podfile.lock文件 - 删除项目对应的
.xcworkspace文件
第二步:适配M1架构重新安装Pods
M1芯片的架构差异可能导致Pod安装异常,按以下步骤操作:
- 打开终端,切换到项目根目录
- 依次执行命令:
pod deintegrate pod setup pod install --repo-update
若上述命令无效,尝试用Rosetta模式打开终端后,执行:
arch -x86_64 pod install --repo-update
第三步:优化Podfile配置
你的Podfile存在两处重复的 use_frameworks!,且Firebase配置有冗余,建议调整后再重新安装:
# platform :ios, '9.0' source 'https://cdn.cocoapods.org/' target 'app' do # Comment the next line if you don't want to use dynamic frameworks use_frameworks! # Pods for app pod 'Applio' pod 'SQLite.swift' pod 'JVFloatLabeledTextField' pod 'MaterialComponents/Snackbar' pod 'iOSDropDown' pod 'Firebase/Analytics' pod 'Firebase/Messaging' pod "BSImagePicker", "~> 3.1" pod "StompClientLib" pod 'SVProgressHUD', '~> 2.2.5' pod 'TPKeyboardAvoiding', '~> 1.3.5' pod 'RangeSeekSlider', '~> 1.8.0' pod 'SDWebImage', '~> 5.12.5' pod 'PureLayout', '~> 3.1.9' pod 'TagListView', :git => 'https://github.com/govindravaliya/TagListView.git', :branch => 'master' pod 'FirebaseAuth' pod 'GoogleSignIn' pod 'GooglePlaces' pod 'RealmSwift' end post_install do |installer| installer.generated_projects.each do |project| project.targets.each do |target| target.build_configurations.each do |config| config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '14.1' xcconfig_path = config.base_configuration_reference.real_path xcconfig = File.read(xcconfig_path) xcconfig_mod = xcconfig.gsub(/DT_TOOLCHAIN_DIR/, "TOOLCHAIN_DIR") File.open(xcconfig_path, "w") { |file| file << xcconfig_mod } end end end end
第四步:Xcode配置检查
- 确保打开的是项目的
.xcworkspace文件,而非.xcodeproj - 进入项目
Build Settings,确认Framework Search Paths包含Pods/Frameworks路径 - 执行
Cmd+Shift+K清理Xcode缓存,重启Xcode后重新编译
内容的提问来源于stack exchange,提问作者That Guy
相关产品推荐
相关产品推荐

