Skip to content

Repository files navigation

Project Icon

Version Swift 6.1 Documentation MIT License

ScanCodes

ScanCodes is a Swift library with scan code-related features for SwiftUI, like a ScanCode and CodeScannerView that can scan QR and barcodes directly into your app.

Demo Gif

Installation

ScanCodes can be installed with the Swift Package Manager:

https://github.com/danielsaidi/ScanCodes.git

Supported Platforms

ScanCodes supports iOS 15, iPadOS 15, macOS 12, tvOS 15, and visionOS 1.

Getting Started

To render a scan code in SwiftUI, just add a ScanCode with the value and type to render:

struct ContentView: View {

    var body: some View {
        ScanCode(
            value: "123456789", 
            type: .qr, 
            scale: 5,
            rotation: .pi/4
        )
    }
}

To add a QR and barcode scanner to your app, that looks for codes to scan, just use the CodeScanner view:

struct ContentView: View {

    @State var code: String?

    var body: some View {
        CodeScannerView(
            code: $code,
            viewfinder: {
                CodeScannerViewfinder()   
            }
        )
    }
}

The code scanner and its viewfinder can be customized to great extent. See the documentation for more details.

Documentation

The online documentation has more information, articles, code examples, etc.

Demo Application

The Demo folder has a demo app that lets you explore the library.

Support My Work

You can become a sponsor to help me dedicate more time on my various open-source tools. Every contribution, no matter the size, makes a real difference in keeping these tools free and actively developed.

Contact

Feel free to reach out if you have questions, or want to contribute in any way:

License

ScanCodes is available under the MIT license. See the LICENSE file for more info.

About

Generate and scan QR codes and bar codes in SwiftUI.

Topics

Resources

Stars

54 stars

Watchers

1 watching

Forks

Releases

Sponsor this project

Contributors

Languages