[null,null,["最后更新时间 (UTC):2025-07-26。"],[[["\u003cp\u003eThe ARCore Cloud Anchor API enables shared AR experiences between iOS and Android devices by allowing users to host and resolve cloud anchors.\u003c/p\u003e\n"],["\u003cp\u003eTo use Cloud Anchors, you need Xcode 13.0+, Cocoapods 1.4.0+ (if using), an ARKit-compatible device running iOS 12.0+, and the ARCore SDK for iOS.\u003c/p\u003e\n"],["\u003cp\u003eThe Cloud Anchors sample app demonstrates key tasks like session setup, Cloud Anchor ID sharing via Firebase, and hosting/resolving anchors.\u003c/p\u003e\n"],["\u003cp\u003eYou can add the ARCore SDK to your own iOS apps by updating your Podfile and running \u003ccode\u003epod update\u003c/code\u003e to install the necessary dependencies.\u003c/p\u003e\n"],["\u003cp\u003ePersistent Cloud Anchors can be created with a time-to-live up to 365 days, allowing for longer-lasting shared AR experiences.\u003c/p\u003e\n"]]],[],null,["# Quickstart for Cloud Anchors in iOS\n\nThe **ARCore Cloud Anchor API** , or **ARCore Cloud Anchor service**, provides cloud anchor capabilities for your iOS apps, making it\npossible for users on both iOS and Android devices to share AR experiences.\n\nThis guide shows you how to:\n\n- Set up your development environment to work with Cloud Anchors\n- Try out hosting and resolving anchors in a sample app\n\nPrerequisites\n-------------\n\n- [Xcode](https://developer.apple.com/xcode/) version 13.0 or later\n- [Cocoapods](https://cocoapods.org/) 1.4.0 or later if using Cocoapods\n- An ARKit-compatible Apple device running iOS 12.0 or later (deployment target of iOS 12.0 or later required)\n\n| **Note:** Beginning with ARCore 1.12, all ARKit-compatible devices are supported.\n\nUsing Cloud Anchors\n-------------------\n\nThe following steps use the Cloud Anchors sample app to show you the critical\ntasks for configuring and building an app that supports ARCore Cloud Anchors.\n\n### Get the Cloud Anchors sample app\n\n1. Clone or download the [ARCore SDK for iOS from GitHub](https://github.com/google-ar/arcore-ios-sdk/releases)\n to obtain the sample app code.\n\n2. Open a Terminal or Finder window and navigate to the folder where you cloned\n or downloaded the SDK.\n\n3. You can find the sample app code in \n\n `/arcore-ios-sdk-master/Examples/CloudAnchorExample`.\n\n The [persistent cloud anchors](#persistent-cloud-anchors) sample app code is\n in \n\n `/arcore-ios-sdk-master/Examples/PersistentCloudAnchorExample`.\n\n### Session setup\n\nThe sample app performs the following important tasks as part of setting up the\nsession:\n\n- Creating a [`GARSession`](/ar/reference/ios/interface_g_a_r_session)\n- Creating an [`ARSession`](https://developer.apple.com/documentation/arkit/arsession) and running it\n- Setting an [`ARSessionDelegate`](https://developer.apple.com/documentation/arkit/arsession/2865614-delegate).\n- Passing [`ARFrame`s](https://developer.apple.com/documentation/arkit/arframe) to the `GARSession` in the `session:didUpdateFrame:` method.\n\n### Set up Cloud Anchor ID sharing\n\nThe Cloud Anchors sample app uses Firebase for sharing Cloud Anchor IDs between\ndevices. You can use a different solution in your own apps.\n\nTo set up Firebase database in the sample app:\n\n1. Follow the Firebase instructions for [adding Firebase to your app](https://firebase.google.com/docs/ios/setup).\n2. Download the `GoogleService-Info.plist` file generated as part of adding Firebase to your app.\n3. Enable Firebase storage for the sample:\n - Go to the **Firebase console** and select the project you set up for the sample app.\n - Select the **Database** panel.\n - On the **Realtime Database** option, click **Get Started**.\n - The **Security rules for Realtime Database** menu opens.\n - For purposes of running the sample, select **Start in test mode**.\n - Note that if you are using Firebase for an app that you plan to publish, you should use more restrictive security rules.\n4. In Xcode, add the `GoogleService-Info.plist` file to your app, next to `Info.plist`.\n\n### Set up the ARCore API\n\nTo use Cloud Anchors, you must first set up the\n[**ARCore API**](/ar/develop/authorization?platform=ios) for your application.\n\n### Run pod update\n\nThe **CloudAnchorExample** app ships with a `Podfile` preconfigured with the\nARCore SDK and iOS versions that you'll need. To install these dependencies:\n\n1. Open a Terminal window and run `pod update` from the folder where the Xcode project exists. \n This generates an `.xcworkspace` file that you'll use later to build and run the app.\n\nSee [Add the ARCore SDK to your app](/ar/develop/ios/cloud-anchors-quickstart-ios#add_the_arcore_sdk_to_your_apps)\nfor details on configuring the `Podfile` in your own apps.\n\n1. Open the `.xcworkspace` file for the project in Xcode.\n\n To avoid build errors, make sure you are building from the `.xcworkspace`\n file and not the `.xcodeproj` file.\n\n### Change the app bundle ID\n\nIn Xcode, change the app's bundle ID so that you can sign the app with your team.\n\n### Build and run the app\n\n1. Connect your device and launch the app in Xcode.\n\n2. (Optional) If you are building and running the sample app, see the following\n section for details on using the app to host and resolve Cloud Anchors.\n\n### Try out the sample app\n\n1. Build and run the sample app from the `.xcworkspace` file to launch\n it on your device.\n\n2. If prompted, grant camera permissions to the app. ARKit then\n starts detecting planes in front of your camera.\n\n3. Tap **HOST** to enter hosting mode. A room code for sharing hosted anchors\n is generated and appears on your screen.\n\n4. Tap a plane to start hosting a cloud anchor there.\n\n - The app places an Andy Android object on the plane and attaches an anchor to it.\n - A host request is sent to the ARCore API cloud endpoint. The host request includes data representing the anchor's position relative to the visual features near it.\n - Once the anchor is hosted, it gets an ID that is used for resolving cloud anchors in this space.\n5. Tap **RESOLVE** and enter a room code to access previously\n hosted Cloud Anchors for this room, using the same or a different device. \n\n - A resolve request is sent to the ARCore API cloud endpoint.\n - The resolve request includes a cloud anchor ID. If the ID matches a hosted anchor and localization is successful, the server returns the transform of the anchor in your local coordinates.\n - The sample app uses the transform to add the anchor to your scene and render virtual objects attached to it.\n\nAdd the ARCore SDK to your apps\n-------------------------------\n\nIn your own apps, you'll need to update your `Podfile` to include the\nARCore SDK and supported iOS versioning. To do this:\n\n1. Add the following `platform` and `pod` to your\n project's `Podfile`:\n\n platform :ios, '11.0'\n pod 'ARCore/CloudAnchors', '~\u003e 1.50.0'\n\n| **Note:** To ensure that your project includes the correct ARCore version, **specify\n| all three of the `ARCore` version digits** in your `pod`. For example, use `1.12.0` instead of `1.12`.\n\n1. Open a Terminal window and run `pod update` from the folder where your Xcode project exists. \n This generates an `.xcworkspace` file that you use to build and run the app.\n\nPersistent cloud anchors\n------------------------\n\nAs described in [Host a Cloud Anchor with persistence](https://developers.google.com/ar/develop/ios/cloud-anchors/developer-guide#host-with-persistence),\nyou can give the cloud anchor a time-to-live up to 365 days. Sample code for\nusing persistent cloud anchors is available in the `/arcore-ios-sdk-master/Examples/PersistentCloudAnchorExample`\ndirectory in the [ARCore SDK for iOS from GitHub](https://github.com/google-ar/arcore-ios-sdk/releases).\n\nNext steps\n----------\n\n- See the [Cloud Anchors Developer Guide for iOS](/ar/develop/ios/cloud-anchors/cloud-anchors-developer-guide-ios)\n to explore the sample app code and learn more about working with Cloud Anchors\n in your own apps.\n\n- Review details in the [ARCore iOS API Reference](/ar/reference/ios)."]]