安装Pod后构建失败?iOS Simulator arm64架构报错求助
问题与解决方案
问题描述
成功安装Pod后,构建.xcworkspace始终失败,无论是否导入Pod,报错如下:
error build: Building for iOS Simulator, but linking in object file built for iOS, file '.../Pods/GoogleMaps/Base/Frameworks/GoogleMapsBase.framework/GoogleMapsBase' for architecture arm64
尝试执行切换命令时出错:
sudo xcode-select --switch /Library/Developer/CommandLineTools/
报错:
error: invalid developer directory '/Library/Developer/CommandLineTools/'
解决方案
一、解决GoogleMaps架构冲突问题
方案1:更新GoogleMaps Pod到最新版本
执行以下命令更新库:
pod update GoogleMaps
更新完成后重新构建项目。
方案2:排除模拟器的arm64架构
- 打开Xcode项目,进入Build Settings,搜索
Excluded Architectures - 在Debug配置下,为iOS Simulator平台添加
arm64 - 在项目的Podfile中添加以下配置,确保Pods目标同步排除架构:
post_install do |installer| installer.pods_project.targets.each do |target| target.build_configurations.each do |config| if config.name == 'Debug' config.build_settings['EXCLUDED_ARCHS[sdk=iphonesimulator*]'] = 'arm64' end end end end
- 执行
pod install重新安装Pods,之后再尝试构建项目。
二、解决xcode-select路径无效问题
- 先查看当前xcode-select的路径:
xcode-select -p
- 切换到Xcode的正确Developer目录(替换为你的Xcode实际路径):
sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
- 如果未安装Command Line Tools,执行以下命令安装:
xcode-select --install
按照弹出的提示完成安装即可。
内容的提问来源于stack exchange,提问作者aisha's SO
相关产品推荐
相关产品推荐

