ARCore 中文文档 下载 App

iOS 平台开发 ARCore 应用配置

两种路线

在 iOS 上做 ARCore 开发有两条路线,取决于你的目标:

路线适用场景说明
ARFoundation + ARKit只做 iOS 且不想学两套 APIUnity 跨平台层,iOS 端底层走 ARKit
ARCore SDK for iOS想在 iOS 上直接用 ARCore APIGoogle 提供的原生 iOS SDK,包含 Cloud Anchors 等跨平台能力

如果你主要做 Android 但需要 Cloud Anchors 跨平台共享,iOS 上用 ARCore SDK 是必须的——ARKit 原生锚点不能和 ARCore 云锚点互通。

路线一:ARCore SDK for iOS

步骤一:添加依赖

ARCore iOS SDK 通过 CocoaPods 或 Swift Package Manager 分发。推荐 Swift Package Manager:

  1. 在 Xcode 中打开项目
  2. 点击 File → Add Package Dependencies
  3. 搜索 https://github.com/google-ar/arcore-ios-sdk
  4. 选择最新稳定版本,添加到目标 Target

或使用 CocoaPods:

pod 'ARCore', '~> 1.49'

步骤二:Info.plist 配置

<!-- 摄像头权限:必须有 -->
<key>NSCameraUsageDescription</key>
<string>需要使用摄像头来创建增强现实体验</string>

<!-- 可选:地理位置权限(Geospatial API 需要) -->
<key>NSLocationWhenInUseUsageDescription</key>
<string>需要使用您的位置信息来实现地理空间增强现实</string>

步骤三:创建 ARSession

ARCore iOS SDK 的 API 设计与 Android 版相似但不完全相同。基本骨架:

import ARCore

class ARViewController: UIViewController, ARSessionDelegate {
    var arSession: GARSession?

    override func viewDidLoad() {
        super.viewDidLoad()

        // 检查设备是否支持 ARCore
        let configuration = GARSessionConfiguration()
        configuration.cloudAnchorMode = .enabled  // 如果需要 Cloud Anchors

        GARSession.isConfigurationSupported(configuration) { supported, error in
            if supported {
                self.arSession = try? GARSession(configuration: configuration)
                self.arSession?.delegate = self
            }
        }
    }
}

Cloud Anchors 在 iOS 上的特别配置

Cloud Anchors 需要额外的 API Key。在 Google Cloud Console 中:

  1. 启用 ARCore Cloud Anchor API
  2. 在项目设置中找到 iOS API Key,配置你的 iOS 应用 Bundle ID
  3. 在 Info.plist 中添加 API Key:
<key>GARAPIKey</key>
<string>YOUR_API_KEY_HERE</string>

Cloud Anchors 在 iOS 上的体验与 Android 基本一致,但少数高级参数(如锚点过期时间)在 iOS 版 SDK 中暴露的较少。

路线二:ARFoundation + ARKit(推荐纯 iOS)

如果你只做 iOS 且不需要 Cloud Anchors 跨平台共享,直接走 ARFoundation + ARKit 是更成熟、性能更好的选择。

配置步骤见 Unity AR Foundation 页面,核心差异:

  1. Build Settings 切换到 iOS 平台
  2. XR Plug-in Management 里勾选 ARKit,不勾选 ARCore
  3. Xcode 里确认 Deployment Target ≥ iOS 12.0
  4. 对于需要人脸特效的场景,确保设备支持 TrueDepth 摄像头(iPhone X+)

iOS 设备支持范围

ARCore iOS SDK 支持 iPhone 6s / iPad Pro(9.7 英寸及以上)之后的所有 iOS 设备。但不同 API 有硬件门槛:

API最低设备
基础运动跟踪iPhone 6s / iPad 2017
Augmented FacesiPhone X+(TrueDepth)/ 部分 iPad Pro
Geospatial VPSiPhone 8+
Cloud AnchorsiPhone 6s+

隐私与合规

iOS 对隐私要求比 Android 严格。几个注意点: