|
| 1 | +# SPQRCode |
| 2 | + |
| 3 | +QR code detector. Simple usage, you can get recognition results via delegate or callback. |
| 4 | + |
| 5 | +- [Installation](#installation) |
| 6 | + - [Swift Package Manager](#swift-package-manager) |
| 7 | + - [CocoaPods](#cocoapods) |
| 8 | + - [Manually](#manually) |
| 9 | +- [Usage](#usage) |
| 10 | + |
| 11 | +## Installation |
| 12 | + |
| 13 | +Ready for use on iOS 11+. |
| 14 | + |
| 15 | +### Swift Package Manager |
| 16 | + |
| 17 | +The [Swift Package Manager](https://swift.org/package-manager/) is a tool for automating the distribution of Swift code and is integrated into the `swift` compiler. It’s integrated with the Swift build system to automate the process of downloading, compiling, and linking dependencies. |
| 18 | + |
| 19 | +Once you have your Swift package set up, adding as a dependency is as easy as adding it to the `dependencies` value of your `Package.swift`. |
| 20 | + |
| 21 | +```swift |
| 22 | +dependencies: [ |
| 23 | + .package(url: "https://github.com/sparrowcode/SPQRCode", .upToNextMajor(from: "1.0.0")) |
| 24 | +] |
| 25 | +``` |
| 26 | + |
| 27 | +### CocoaPods: |
| 28 | + |
| 29 | +[CocoaPods](https://cocoapods.org) is a dependency manager. For usage and installation instructions, visit their website. To integrate using CocoaPods, specify it in your `Podfile`: |
| 30 | + |
| 31 | +```ruby |
| 32 | +pod 'SPQRCode' |
| 33 | +``` |
| 34 | + |
| 35 | +### Manually |
| 36 | + |
| 37 | +If you prefer not to use any of dependency managers, you can integrate manually. Put `Sources/SPSafeSymbols` folder in your Xcode project. Make sure to enable `Copy items if needed` and `Create groups`. |
| 38 | + |
| 39 | +## Usage |
| 40 | + |
| 41 | +To show QRCode scanner: |
| 42 | + |
| 43 | +```swift |
| 44 | +let qrCodeController = SPQRCodeViewController() |
| 45 | + |
| 46 | +qrCodeController.cameraFoundHandler = { value in |
| 47 | + print(value) |
| 48 | +} |
| 49 | + |
| 50 | +viewController.present(qrCodeController, animated: true, completion: nil) |
| 51 | +``` |
| 52 | + |
| 53 | +If need with specific view for frame and preview, use this: |
| 54 | + |
| 55 | +```swift |
| 56 | +let frameView = UIView() |
| 57 | +frameView.layer.borderWidth = 3.0 |
| 58 | + |
| 59 | +let previewLabel = UILabel() |
| 60 | + |
| 61 | +let qrCodeController = SPQRCodeViewController() |
| 62 | +qrCodeController.customFrameView = frameView |
| 63 | +qrCodeController.customPreviewView = previewLabel |
| 64 | + |
| 65 | +qrCodeController.cameraFoundHandler = { [weak previewLabel] value in |
| 66 | + previewLabel?.text = value |
| 67 | +} |
| 68 | + |
| 69 | +viewController.present(qrCodeController, animated: true, completion: nil) |
| 70 | +``` |
| 71 | + |
| 72 | +Optionaly you can create subclass of `SPQRCodeViewController` for more control |
0 commit comments