카메라를 이용하여 QR code를 스캔할 수 있는 CodeScanner 프레임워크가 있습니다

https://github.com/twostraws/CodeScanner

 

GitHub - twostraws/CodeScanner: A SwiftUI view that is able to scan barcodes, QR codes, and more, and send back what was found.

A SwiftUI view that is able to scan barcodes, QR codes, and more, and send back what was found. - twostraws/CodeScanner

github.com

CodeScanner 프레임워크 추가하기

카메라를 이용하여 QR code를 스캔할 수 있도록 구현된 CodeScanner 프레임워크를 SPM으로 추가해줍니다.

https://github.com/twostraws/CodeScanner.git

 

info 설정

CodeScanner를 사용하기 위한 Info 설정을 해야합니다

 

QR code 스캔을 위한 CodeScannerView 사용합니다,

struct ContentView: View {
    var body: some View {
        
        CodeScannerView(codeTypes: [.qr], simulatedData: "Paul Hudson") { response in
            switch response {
            case .success(let result):
                print("Found code: \(result.string)")
            case .failure(let error):
                print(error.localizedDescription)
            }
        }
    }
}

 

위에 View로 생성된 카메라 화면으로 아래 코드를 스캔하게되면 아래와 같은 print문이 출력됩니다.

 

ytw_developer