<!--
{
  "availability" : [
    "iOS: 13.0.0 -",
    "iPadOS: 13.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.15.0 -",
    "tvOS: 13.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreImage",
  "identifier" : "/documentation/CoreImage/CIFilter-swift.class/barcodeGenerator()",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "Core Image",
      "CoreImage"
    ],
    "preciseIdentifier" : "c:objc(cs)CIFilter(cm)barcodeGeneratorFilter"
  },
  "title" : "barcodeGenerator()"
}
-->

# barcodeGenerator()

Generates a barcode as an image from the descriptor.

```
class func barcodeGenerator() -> any CIFilter & CIBarcodeGenerator
```

## Return Value

The generated image.

## Discussion

This method generates a custom barcode as an image. The effect uses barcode descriptors to specify properties of the generated barcode.

The barcode generator uses the following property:

- `barcodeDescriptor`: An instance of [`CIBarcodeDescriptor`](/documentation/CoreImage/CIBarcodeDescriptor) with the input parameters supplied.

The following code creates a filter that generates a QR code containing the text *Johnny Appleseed.*

```swift
func barcode(inputMessage: Data) -> CIImage {
   let barcodeGenerator = CIFilter.barcodeGenerator()
    barcodeGenerator.barcodeDescriptor = CIQRCodeDescriptor(payload: inputMessage, symbolVersion: 1, maskPattern: 4, errorCorrectionLevel: .levelL)!
    return barcodeGenerator.outputImage!
}

let johnnyAppleseed: [UInt8] = [0x41, 0x04, 0xA6, 0xF6, 0x86, 0xE6, 0xE7, 0x92, 0x04, 0x17, 0x07, 0x06, 0xC6, 0x57, 0x36, 0x56, 0x56, 0x40, 0xEC]
let data = Data(johnnyAppleseed)

let bImage = barcode(inputMessage: data)
```

![A QR code containing the text Johnny Appleseed.](images/com.apple.coreimage/media-4327881@2x.png)

## See Also

[`CIAztecCodeDescriptor`](/documentation/CoreImage/CIAztecCodeDescriptor)

A concrete subclass the Core Image Barcode Descriptor that represents an Aztec code symbol.

[`CIDataMatrixCodeDescriptor`](/documentation/CoreImage/CIDataMatrixCodeDescriptor)

A concrete subclass the Core Image Barcode Descriptor that represents an Data Matrix code symbol.

[`CIPDF417CodeDescriptor`](/documentation/CoreImage/CIPDF417CodeDescriptor)

A concrete subclass of Core Image Barcode Descriptor that represents a PDF417 symbol.

[`CIQRCodeDescriptor`](/documentation/CoreImage/CIQRCodeDescriptor)

A concrete subclass of the Core Image Barcode Descriptor that represents a square QR code symbol.



---

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)