Skip to content

Tools to validate and to generate SwiftUI views for various barcode formats (EAN-8, EAN-13, UPC-E, UPC-A)

License

Notifications You must be signed in to change notification settings

villeheikkila/BarcodeToolsKit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BarcodeToolsKit

BarcodeToolsKit provides additional tools for working with barcodes with SwiftUI. It provides a way to validate barcodes and render those using SwiftUI canvas. It also provides a scanner that is limited to scanning the supported barcode types.

Currently supported types include EAN-8, EAN-13, UPC-A and UPC-E.

Installation

Install using SPM

dependencies: [
    .package(url: "https://github.com/villeheikkila/BarcodeToolsKit", from: "1.0.0"),
],
targets: [
    .target(name: "MyTarget", dependencies: [
        .product(name: "BarcodeToolsKit", package: "BarcodeToolsKit"),
    ]),
]

Import where needed

import BarcodeToolsKit

Requirements

  • Swift 6.0+
  • iOS/iPadOS/tvOS 17+, watchOS 9, macOS 12+, visionOS 1+

Usage

View

Generate a barcode for a given code, you can also give an optional view that will be used for unsupported unsupported or malformatted codes

BarcodeView(barcode: "6410405176059") {
    ContentUnavailableView(
        "Unsupported Barcode Type",
        systemImage: "barcode"
    )
    .symbolVariant(.slash)
}
.barcodeStyle(.plain)
.barcodeLineColor(.black)

You can optionally specify the barcode style and color

Default Style

Default Style

Plain Style

Default Style

Scan a barcode

BarcodeScannerView {
    barcode in print(barcode)
}

About

Tools to validate and to generate SwiftUI views for various barcode formats (EAN-8, EAN-13, UPC-E, UPC-A)

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages