Unity开发AR应用Xcode编译报错:未找到ARCoreBase.xcframework
解决Xcode编译ARCore应用时找不到ARCoreBase.xcframework的问题
问题场景
- 使用Unity 2021.3.27f1结合Google ARCore Geospatial API开发AR应用,Unity端编译无报错
- 导出Xcode工程后,在iPad上编译触发以下错误:
Framework not found ARCoreBase.xcframeworklinker command failed with exit code 1 (use -v to see invocation)
- 开发环境:Xcode 14.3.1、Mac mini(M2Pro) macOS Ventura 13.4.1
- 已尝试操作:安装pods、打开.xcworkspace、更新Unity包,问题未解决;推测Podfile未包含ARCore/Base依赖是核心原因
解决方案
1. 补充Podfile中的ARCore基础依赖
你的Podfile确实缺少了ARCore的基础组件依赖,需将ARCore/Base添加到UnityFramework目标中,修改后的Podfile内容如下:
source 'https://cdn.cocoapods.org/' platform: ios, '12.0' target 'UnityFramework' do pod 'ARCore/Base', '~> 1.37.0' pod 'ARCore/GARSession', '~> 1.37.0' pod 'ARCore/Geospatial', '~> 1.37.0' end target 'Unity-iPhone' do end use_frameworks! :linkage => :static
修改完成后,在Xcode工程根目录执行以下命令更新依赖:
pod install --repo-update
2. 校验Unity端ARCore配置
- 打开Unity编辑器,进入
Project Settings > XR Plug-in Management > ARCore,确认Geospatial选项已勾选 - 检查
Player Settings > Other Settings中的Target Minimum iOS Version是否设置为12.0或更高,需与Podfile中的版本一致 - 重新导出Xcode工程,避免导出过程中遗漏必要文件
3. 清理Xcode缓存与构建残留
- 关闭Xcode,删除工程目录下的
DerivedData文件夹(可通过Xcode > Preferences > Locations查看并定位该路径) - 在Xcode中执行
Product > Clean Build Folder(快捷键Shift+Command+K) - 重新打开
.xcworkspace文件后尝试编译
4. 确认ARCoreBase.xcframework是否存在
- 打开Podfile所在目录的
Pods/ARCore文件夹,检查ARCoreBase.xcframework是否存在 - 若文件缺失,执行
pod deintegrate移除现有pod依赖,再重新执行pod install完成全量安装
5. 检查Xcode的Framework搜索路径
- 在Xcode中选中
UnityFramework目标,进入Build Settings页面 - 搜索
Framework Search Paths,确保包含$(PROJECT_DIR)/Pods/ARCore路径,并设置为recursive - 若路径缺失,手动添加该路径后重新编译
内容的提问来源于stack exchange,提问作者imami
相关产品推荐
相关产品推荐

