Google is committed to advancing racial equity for Black communities. See how.

Build the Cloud Anchors sample app in ARCore Extensions for iOS

Use the CloudAnchors sample app to build your first AR experience that Android and iOS users can share.

Required prerequisites

Familiarizing yourself with the following concepts isn't required, but it will help you better understand how the Cloud Anchors sample app works.

Set up your development environment

Set up your development environment for trying out the sample app.

About Cloud Anchors ID sharing

The CloudAnchors sample app uses Unity's networking feature for sharing Cloud Anchor IDs between devices on the same network.

You can use a different solution in your own apps.

Add an API Key

To use the ARCore Cloud Anchor API in your app, you'll need an API Key.

  1. Obtain an API Key.

    If you're new to API keys, see Setting up API keys.

  2. Enable the ARCore Cloud Anchor API for your Google Cloud Platform project.

  3. Complete the following steps to add your API key to your project.

    • In Unity, go to Edit > Project Settings > XR > ARCore Extensions.

    • Select the iOS Support Enabled checkbox.

    • Under Cloud Anchor API Keys, add your API key to the iOS field.

Install and open the sample

The CloudAnchors sample is included with the ARCore Extensions package.

  1. In Unity, open the Package Manager (choose Window > Package Manager).

  2. Select the ARCore Extensions package.

  3. In the description, click Import into Project for the Cloud Anchor sample, and wait for the files to be added to your project.

  4. In the Unity project window, open the scene located at

    Assets/Samples/ARCore Extensions/<version>/Cloud Anchor Sample/Scenes/CloudAnchors.

Configure build and platform settings

  1. Add the sample scene to your build:

    • Go to File > Build Settings and click Add open scene.
    • Select CloudAnchors. Disable any other scenes in the build.
  2. Follow the Configure build and platform settings steps in the Quickstart for iOS.

  3. This example uses the Unity Multiplayer API. To be able to use multiplayer services, you must set up project services and set up multiplayer.

Try out the sample app

To try out your sample app, build the app and launch it. Then you can host and resolve Cloud Anchors.

To build and launch the app:

  1. In Unity, click Build and select an output folder for your iOS Xcode project. An Xcode project is generated.

  2. Go to your Xcode output folder and open the Unity-iPhone.xcworkspace file in Xcode.
    To avoid build errors, do not build or launch from the included Unity-iPhone.xcodeproj project file.

  3. In Xcode, select the Unity-iPhone project in the left pane, connect your phone, and launch the app.

To host and resolve Cloud Anchors:

  1. The sample app launches on your phone. Create a room with the host device. The app will display a room code which can be used to join this room from another device.

  2. Move your phone around until ARCore starts detecting and visualizing planes.

  3. Tap a plane to create an anchor object on it. A host request is sent to the Google Cloud Anchor service. The host request includes data representing the anchor's position relative to the visual features near it.

  4. After the Cloud Anchor is successfully hosted, subsequent taps will create Star objects, which will be synchronized across devices using Unity Multiplayer Services.

  5. Launch the example from a new device, and join the room you created previously. A request is sent to the Google Cloud Anchor service to resolve the pose of the cloud anchor. When this request returns successfully, the sample app renders the anchor using the pose.

  6. Both devices will now be able to tap the screen to place Stars.

Next steps