<!--
{
  "availability" : [
    "iOS: 12.0.0 - 27.0.0",
    "iPadOS: 12.0.0 - 27.0.0"
  ],
  "documentType" : "symbol",
  "framework" : "ARKit",
  "identifier" : "/documentation/ARKit/ARReferenceObject/merging(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "ARKit"
    ],
    "preciseIdentifier" : "c:objc(cs)ARReferenceObject(im)referenceObjectByMergingObject:error:"
  },
  "title" : "merging(_:)"
}
-->

# merging(_:)

Returns a new reference object that combines spatial information from both this reference object and another.

```
func merging(_ object: ARReferenceObject) throws -> ARReferenceObject
```

## Parameters

`object`

The other reference object with which to combine this reference object.

## Return Value

A new [`ARReferenceObject`](/documentation/ARKit/ARReferenceObject) that includes the spatial information from both objects. From Swift, this method throws an [`ARError`](/documentation/ARKit/ARError) if the two objects cannot be merged. From Objective-C, it returns `nil` and populates the `error` parameter with a description of the failure.

## Discussion

The accuracy of 3D object detection depends on similarity of lighting and environmental conditions between when you scan a real object (producing an [`ARReferenceObject`](/documentation/ARKit/ARReferenceObject)) and when a user of your app attempts to detect that object. If, for example, you scan an object in a bright environment, then a user attempts to detect it in a dark environment, ARKit may fail to recognize that the real object matches the reference object, or may not detect the object quickly.

To make a reference object that is more robust in a wide variety of detection conditions, scan the same real-world object multiple times: For each scan, vary the lighting conditions or the background environment to capture the variety of situations in which your app might attempt to detect the same real object. Then, use this method to combine those scan results into a single [`ARReferenceObject`](/documentation/ARKit/ARReferenceObject) incorporating recognition information for all the conditions you scanned in.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)