A shared object that manages the device camera and motion processing needed for augmented reality experiences.


class ARSession : NSObject


An ARSession object coordinates the major processes that ARKit performs on your behalf to create an augmented reality experience. These processes include reading data from the device's motion sensing hardware, controlling the device's built-in camera, and performing image analysis on captured camera images. The session synthesizes all of these results to establish a correspondence between the real-world space the device inhabits and a virtual space where you model AR content.

Every AR experience built with ARKit requires a single ARSession object. If you use an ARSCNView or ARSKView object to easily build the visual part of your AR experience, the view object includes an ARSession instance. If you build your own renderer for AR content, you'll need to instantiate and maintain an ARSession object yourself.

Running a session requires a configuration. Subclasses of the abstract ARConfiguration class determine how ARKit tracks a device's position and motion relative to the real world, and thus affect the kinds of AR experiences you can create. For example, use ARWorldTrackingConfiguration for experiences that augment the user's view of the world around them though the device's back camera.


Configuring and Running a Session

func run(ARConfiguration, options: ARSession.RunOptions)

Starts AR processing for the session with the specified configuration and options.

struct ARSession.RunOptions

Options affecting how to transition an AR session's current state when you change its configuration.

var configuration: ARConfiguration?

An object that defines motion and scene tracking behaviors for the session.

func pause()

Pauses processing in the session.

Responding to AR Updates

var delegate: ARSessionDelegate?

An object you provide to receive captured video images and tracking information, or to respond to changes in session status.

var delegateQueue: DispatchQueue?

The dispatch queue through which the session calls your delegate methods.

protocol ARSessionDelegate

Methods you can implement to receive captured video frame images and tracking state from an AR session.

protocol ARSessionObserver

Methods you can implement to respond to changes in the state of an AR session.

Displaying and Interacting with AR Content

var currentFrame: ARFrame?

The video frame image, with associated AR scene information, most recently captured by the session.

func add(anchor: ARAnchor)

Adds the specified anchor to be tracked by the session.

func remove(anchor: ARAnchor)

Removes the specified anchor from tracking by the session.

Saving or Sharing Session State

func getCurrentWorldMap(completionHandler: (ARWorldMap?, Error?) -> Void)

Returns an object encapsulating the world-tracking session's space-mapping state and set of anchors.

Scanning 3D Objects for Detection

func createReferenceObject(transform: simd_float4x4, center: simd_float3, extent: simd_float3, completionHandler: (ARReferenceObject?, Error?) -> Void)

Creates a reference object (for 3D object detection) from the specified region of the session’s world space.

Updating the World Origin

func setWorldOrigin(relativeTransform: simd_float4x4)

Changes the basis for the AR world coordinate space using the specified transform.


Inherits From

Conforms To

See Also

First Steps

Verifying Device Support and User Permission

Make sure your app can use ARKit and respects user privacy.

class ARConfiguration

The abstract base class for AR session configurations.