iOS QR Code Scanner
A Simple iOS QR code scanner using Swift UI.
NOTE: be aware of the new horizontal line error to internal hyperlink redirecting in Documentations
Append the ‘hr’ command right after the preceeding line of documentation to enure the overall formatting stability.
Developing tool: Xcode
13.4+ Swift, SwiftUI custom dependencies.
iPhone 11, iPhone 12, iPhone 13, iPad 10.2+
In Xcode IDE, go to info, click to add a Custom iOS Target Properties Key
Search for Privacy –
Camera Usage Description
Value String: “We need the camera to scan the QR code” ->
This preset will enable users to turn on their camera Privacy for scanning
Secondarily, click to add
Appearance Value String: Light ->
If the app is used on a physical device, this functionality will automatically maximize the brightness on the user’s devices for better scannability if QR code is detected.
Next, click File->Add Packages…-> add CodeScannerDependency into Package Dependencies.
In order to prevent the occurence of
“Cannot assign value of type ‘ScanResult’ to type ‘String’ “ error
self.scannedCode = code
we need to use
self.scannedCode = code.string
instead to make the value types compatible.
Must customize commit message for each commit:
Changes done in ContentView.swift file-> Save -> Source Control->Commit->Flat->Selected the committed file->Enter customized commit message down below->Select Push to Remote (origin/origin/main)-> Commit N files. Done Committing.
NOTE: To retain each commit to Github Repositories:
Must save -> resume -> rebuild on Simulator -> push both hierarchical and flat modified files and assets remotely to the Github origin/main.
Method Running The Project
Download the project to local directory
Xcode must be
13.4 and higher versions
Compatible with MacOS Monterey
12.0 or higher versions
Enable Camera access or Local Photo Library access in local device.
Online QR code generator
Starting UI that prompts user to scan a QR code to get started:
iOS 15.5 Simulator message. Camera access isn’t available on Xcode Simulator, so select a custom image:
Testing on url link:
Testing on random text:
Testing on image:
Krystal Zhang https://github.com/KrystalZhang612
This file was generated by QRCodeScanner-readme, on June 18, 2022