Configure your app's settings so that it can use the [Geospatial API](https://developers.google.com/ar/develop/geospatial).

## Prerequisites

Make sure that you understand [fundamental AR concepts](https://developers.google.com/ar/develop/fundamentals)
and how to [configure an ARCore session](https://developers.google.com/ar/develop/ios/session-config) before proceeding.

If you want to run a sample app that demonstrates the functionality described
here, see the
[ARCore Geospatial quickstart for iOS](https://developers.google.com/ar/develop/ios/geospatial/quickstart).

See the
[Introduction to the Geospatial API](https://developers.google.com/ar/develop/geospatial) for more
information about the Geospatial API.

If you're new to developing with ARCore, see [Getting started](https://developers.google.com/ar/develop/getting-started)
for information about software and hardware requirements, prerequisities and
other information specific to the platforms you are using.

## Enable the ARCore API

Before using the Visual Positioning System (VPS) in your app, you must first
enable the [**ARCore API**](https://developers.google.com/ar/develop/authorization?platform=ios)
in a new or existing Google Cloud project. This service is responsible for
hosting, storing, and resolving Geospatial anchors.

Keyless authorization is preferred, but API Key authorization is also supported.

## Add required libraries to your app

After authorizing your app to call the ARCore API, you must add libraries to
enable Geospatial features in your app.
Update the `Podfile` for your app to include the ARCore SDK and supported iOS versioning. To do this:

<br />

1. Add the following `platform` and `pod` to your
   project's `Podfile`:

       platform :ios, '11.0'
       pod 'ARCore/Geospatial', '~> 1.56.0'

   You may also specify `platform :ios, '10.0'`, if you want to support iOS 10,
   but note that the Geospatial API will only function at runtime on iOS \>= 11.

   > [!NOTE]
   > **Note:** To ensure that your project includes the correct ARCore version, **specify
   > all three of the `ARCore` version digits** in your `pod`. For example, use `1.31.0` instead of `1.31`.

2. Open a Terminal window and run `pod install` from the folder where
   your Xcode project exists.  

   This generates an `.xcworkspace` file that you use to build and
   run the app.

Be sure your development environment satisfies the ARCore SDK requirements, as
described in the [Quickstart](https://developers.google.com/ar/develop/ios/geospatial/quickstart).

## Enable Geospatial capabilities in the session configuration

## Check device compatibility

Not all devices that support ARCore also support the Geospatial API, as
described in the [quickstart](https://developers.google.com/ar/develop/ios/geospatial/quickstart#device-support).

Use
[`GARSession.isGeospatialModeSupported:`](https://developers.google.com/ar/reference/ios/interface_g_a_r_session#ae0bdf3c3c987a5c3df8914c6fcd3c5a6)
to check the device, as in the following:

    if (![self.garSession isGeospatialModeSupported:GARGeospatialModeEnabled]) {
      [self setErrorStatus:@"GARGeospatialModeEnabled is not supported on this device."];
      return;
    }

    GARSessionConfiguration *configuration = [[GARSessionConfiguration alloc] init];
    configuration.geospatialMode = GARGeospatialModeEnabled;
    [self.garSession setConfiguration:configuration error:&error];
    if (error) {
      [self setErrorStatus:[NSString stringWithFormat:@"Failed to configure GARSession: %d",
                                                      (int)error.code]];
      return;
    }

## Ask user for location permissions at runtime

Your app must request the following location permissions at runtime, before
configuring the session:

- [`kCLAuthorizationStatusAuthorizedWhenInUse`](https://developer.apple.com/documentation/corelocation/clauthorizationstatus/kclauthorizationstatusauthorizedwheninuse)
- [`CLAccuracyAuthorizationFullAccuracy`](https://developer.apple.com/documentation/corelocation/claccuracyauthorization/claccuracyauthorizationfullaccuracy?language=objc) (Applies when iOS \>= 14)

## Check Geospatial availability at the device's current location

Because the Geospatial API uses a combination of [VPS](https://developers.google.com/ar/develop/geospatial#global_localization_with_vps) and GPS to determine a Geospatial transform, the API can be used as long as the device is able to determine its location. In areas with low GPS accuracy, such as indoor spaces and dense urban environments, the API will rely on VPS coverage to generate high accuracy transforms. Under typical conditions, VPS can be expected to provide positional accuracy of approximately 5 meters, and rotational accuracy of 5 degrees. Use [`GARSession.checkVPSAvailabilityAtCoordinate:completionHandler:`](https://developers.google.com/ar/reference/ios/category_g_a_r_session_07_geospatial_08#ab4c2672d3a5f1869663ddb72d1c83189) to determine if a given location has VPS coverage.

The Geospatial API can also be used in areas that do not have VPS coverage. In outdoor environments with few or no overhead obstructions, GPS may be sufficient to generate a transform with high accuracy.

## What's next

- [Obtain the device camera's Geospatial transform](https://developers.google.com/ar/develop/ios/geospatial/obtain-device-pose) to determine the exact location of the user's device in the real world.
- [Check VPS availability](https://developers.google.com/ar/develop/ios/geospatial/check-vps-availability) at a device's given location.