<!--
{
  "availability" : [
    "iOS: 27.0.0 -",
    "iPadOS: 27.0.0 -",
    "macOS: 27.0.0 -",
    "visionOS: 27.0.0 -",
    "watchOS: 27.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Vision",
  "identifier" : "/documentation/Vision/BarcodeReaderTool",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "Vision",
      "FoundationModels"
    ],
    "preciseIdentifier" : "s:24_Vision_FoundationModels17BarcodeReaderToolV"
  },
  "title" : "BarcodeReaderTool"
}
-->

# BarcodeReaderTool

A tool that scans machine-readable codes in an image.

```
struct BarcodeReaderTool
```

## Overview

When the model encounters an image containing machine-readable codes, it can call this tool
to decode them. The tool returns an array of `Barcode` results, each containing the
decoded content and the symbology type.

To enable this tool, configure your
`LanguageModelSession` with an instance of `BarcodeReaderTool`.

```swift
let barcodeTool = BarcodeReaderTool()
let session = LanguageModelSession(tools: [barcodeTool])
```

You can override the default name and description to customize how the model
identifies and uses the tool.

```swift
let customTool = BarcodeReaderTool(
    name: "scanQRCode",
    description: "Scan QR codes"
)
```

> Note:
> ``doc://Vision/documentation/Vision/BarcodeReaderTool`` isn’t available in Simulator.

## Topics

### Creating a tool

[`init(name:description:)`](/documentation/Vision/BarcodeReaderTool/init(name:description:))

Creates a tool for decoding machine-readable codes.



---

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)