Swiftpack.co - nasa-jpl/ScanBarcodes as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by nasa-jpl.
nasa-jpl/ScanBarcodes 1.0.5
ScanBarcodes is a SwiftUI view that scans barcodes using an iPhone or iPad camera.
⭐️ 3
🕓 2 weeks ago
.package(url: "https://github.com/nasa-jpl/ScanBarcodes.git", from: "1.0.5")


ScanBarcodes is a SwiftUI view that scans barcodes using an iPhone or iPad camera.

The framework uses AVFoundation for high performance video capture and barcode recognition. The view also provides optional control of the flashlight and the zoom level of the camera.

Getting started

Try the demo application

Two important notes on usage:

  1. an actual phone is required (iOS simulator doesn't yet support the camera)
  2. an entry in the app Info.plist for "Privacy - Camera Usage Description" is required to prompt for user permission to use the camera to scan barcodes.

The view takes two required arguments and two optional arguments:

  • barcodeTypes: [AVMetadataMachineReadableCodeObject.ObjectType] (required)
  • zoomLevel : Binding<Int> (optional, defaults to 1, values greater than 1 increase the zoom)
  • flashlightOn: Binding<Bool> (optional, defaults to false)
  • completion: @escaping (Result<String, BarcodeScanError>) -> Void) (required, a closure to execute when a result is obtained)


Copyright © 2021 California Institute of Technology. ALL RIGHTS RESERVED. United States Government Sponsorship Acknowledged.


Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at


Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.


This project was based on CodeScanner by Paul Hudson and liberally modified.


Stars: 3
Last commit: 2 weeks ago
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics