Xcode 15报错:找不到__ObjC模块及CocoaPods编译设置冲突
问题描述
执行pod install时出现以下警告:
[!] The
Runner [Debug]target overrides theENABLE_BITCODEbuild setting defined in `Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig'. This can lead to problems with the CocoaPods installation
- Use the
$(inherited)flag, or- Remove the build settings from the target.
[!] The
Runner [Release]target overrides theENABLE_BITCODEbuild setting defined in `Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig'. This can lead to problems with the CocoaPods installation
- Use the
$(inherited)flag, or- Remove the build settings from the target.
[!] The
Runner [Profile]target overrides theENABLE_BITCODEbuild setting defined in `Pods/Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig'. This can lead to problems with the CocoaPods installation
- Use the
$(inherited)flag, or- Remove the build settings from the target.
之后真机调试时,Xcode抛出错误:no such module '__ObjC'
解决步骤
1. 修复CocoaPods的ENABLE_BITCODE警告
打开Xcode,选中Runner target,按以下操作处理:
- 切换到Build Settings标签页
- 在搜索框输入
ENABLE_BITCODE - 找到对应设置项,给Debug、Release、Profile三个配置的输入框都填入
$(inherited) - 保存设置后重新执行
pod install,警告即可消除
2. 解决no such module '__ObjC'错误
尝试以下操作逐一排查:
- 清理编译缓存:点击菜单栏
Product->Clean Build Folder(快捷键Cmd+Shift+K) - 删除Derived Data:打开Xcode偏好设置(
Cmd+,),选择Locations,点击Derived Data旁的箭头,删除当前项目的缓存文件夹 - 检查
Runnertarget的Build Settings里的Other Swift Flags,确保配置无误,或尝试添加-Xcc -fmodules - 重启Xcode后重新编译项目
内容的提问来源于stack exchange,提问作者Aqib shahzad

