在 iOS 中配置 ARCore 会话
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
配置 ARCore 会话,为您的应用打造 AR 体验。
什么是会话?
所有 AR 进程(例如动作跟踪、环境理解和光照估测)都发生在 ARCore 会话内。GARSession
是 ARCore API 的主入口点。它管理 AR 系统状态并处理会话生命周期,允许应用创建、配置、启动或停止会话。最重要的是,它使应用能够接收允许访问相机图片和设备姿势的帧。
会话可用于配置以下功能:
如需使用 Cloud Anchors API 或 Geospatial API,则必须使用 cloudAnchorMode
或 geospatialMode
属性创建 GARSessionConfiguration:
在 iOS 中创建会话
后续步骤
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-26。
[null,null,["最后更新时间 (UTC):2025-07-26。"],[[["\u003cp\u003eAn ARCore session, represented by \u003ccode\u003eGARSession\u003c/code\u003e, manages all AR processes like motion tracking and environmental understanding.\u003c/p\u003e\n"],["\u003cp\u003eYou can configure a session to use features such as Cloud Anchors, Augmented Faces, and the ARCore Geospatial API.\u003c/p\u003e\n"],["\u003cp\u003eTo create a session in iOS, you need to initialize \u003ccode\u003eGARSession\u003c/code\u003e, set delegates for callbacks, and integrate with ARKit's \u003ccode\u003eARSession\u003c/code\u003e for frame processing.\u003c/p\u003e\n"],["\u003cp\u003eSession configuration allows enabling specific features like Cloud Anchors or the Geospatial API by setting properties on \u003ccode\u003eGARSessionConfiguration\u003c/code\u003e.\u003c/p\u003e\n"]]],[],null,["# Configure an ARCore session in iOS\n\nConfigure an ARCore session to build AR experiences for your app.\n\nWhat is a session?\n------------------\n\nAll [AR processes](/ar/discover/concepts), such as motion tracking,\nenvironmental understanding, and lighting estimation, happen inside an ARCore\nsession. [`GARSession`](/ar/reference/ios/interface_g_a_r_session) is the main entry point to the ARCore\nAPI. It manages the AR system state and handles the session lifecycle, allowing\nthe app to create, configure, start, or stop a session. Most importantly, it\nenables the app to receive frames that allow access to the camera image and\ndevice pose.\n\nThe session can be used to configure the following features:\n\n- [Cloud Anchors](/ar/develop/cloud-anchors)\n- [Augmented Faces](/ar/develop/augmented-faces)\n- [ARCore Geospatial API](/ar/develop/geospatial)\n\nConfigure a session\n-------------------\n\nTo use either the [Cloud Anchors](/ar/develop/cloud-anchors) API or the\n[Geospatial](/ar/develop/geospatial) API, you have to create a\n[GARSessionConfiguration](/ar/reference/ios/interface_g_a_r_session_configuration)\nwith either the `cloudAnchorMode` or `geospatialMode` property:\n\n- create a\n [`GARSessionConfiguration`](/ar/reference/ios/interface_g_a_r_session_configuration)\n and set the `geospatialMode` or `cloudAnchorMode` property for it.\n\n- Use\n [`setConfiguration:error: (GARSession)`](/ar/reference/ios/interface_g_a_r_session#aa30bf763b9b1006371f6c93294bd76f5)\n to set the configuration.\n\nCreate a session in iOS\n-----------------------\n\n- Create a [`GARSession`](/ar/reference/ios/interface_g_a_r_session).\n- Set a [`GARSessionDelegate`](/ar/reference/ios/protocol_g_a_r_session_delegate-p) to get callbacks from hosting and resolving operations.\n- Create and run an [`ARSession`](https://developer.apple.com/documentation/arkit/arsession).\n- Set an [`ARSessionDelegate`](https://developer.apple.com/documentation/arkit/arsession/2865614-delegate).\n- Pass [`ARFrame`s](https://developer.apple.com/documentation/arkit/arframe) to the `GARSession` in the `session:didUpdateFrame:` method.\n\nNext steps\n----------\n\n- [Cloud Anchors for iOS](/ar/develop/ios/cloud-anchors/overview)\n- [Augmented Faces for iOS](/ar/develop/ios/augmented-faces/overview)\n- [ARCore Geospatial API](/ar/develop/geospatial)"]]