{"id":21903930,"url":"https://github.com/hansemannn/ios11-qr-code-example","last_synced_at":"2025-06-12T06:34:18.510Z","repository":{"id":142791150,"uuid":"93883069","full_name":"hansemannn/iOS11-QR-Code-Example","owner":"hansemannn","description":"Example showing how to use the QR-code detection API (VNDetectBarcodesRequest) in iOS 11.","archived":false,"fork":false,"pushed_at":"2018-01-13T18:57:23.000Z","size":36,"stargazers_count":86,"open_issues_count":2,"forks_count":15,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-29T01:12:32.509Z","etag":null,"topics":["ios11","qrcode","vision"],"latest_commit_sha":null,"homepage":null,"language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hansemannn.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-06-09T17:44:58.000Z","updated_at":"2024-07-01T17:29:10.000Z","dependencies_parsed_at":"2023-06-19T10:05:20.739Z","dependency_job_id":null,"html_url":"https://github.com/hansemannn/iOS11-QR-Code-Example","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hansemannn%2FiOS11-QR-Code-Example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hansemannn%2FiOS11-QR-Code-Example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hansemannn%2FiOS11-QR-Code-Example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hansemannn%2FiOS11-QR-Code-Example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hansemannn","download_url":"https://codeload.github.com/hansemannn/iOS11-QR-Code-Example/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249152866,"owners_count":21221319,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ios11","qrcode","vision"],"created_at":"2024-11-28T15:30:16.784Z","updated_at":"2025-04-15T20:46:26.702Z","avatar_url":"https://github.com/hansemannn.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🔲 iOS11 QR-Code Example\nA quick example showing how to use the `Vision` system-framework in iOS 11 and Swift 4.\n\n## Prerequisites\n* Xcode 9 and later\n\n## Getting Started\nFirst, import the `Vision` framework.\n```swift\nimport Vision\n```\nNext, create a barcode-request that will call the completion-handler asynchronously when it detects a code:\n```swift\n// Create a barcode detection-request\nlet barcodeRequest = VNDetectBarcodesRequest(completionHandler: { request, error in\n\n    guard let results = request.results else { return }\n\n    // Loopm through the found results\n    for result in results {\n        \n        // Cast the result to a barcode-observation\n        if let barcode = result as? VNBarcodeObservation {\n            \n            // Print barcode-values\n            print(\"Symbology: \\(barcode.symbology.rawValue)\")\n            \n            if let desc = barcode.barcodeDescriptor as? CIQRCodeDescriptor {\n                let content = String(data: desc.errorCorrectedPayload, encoding: .utf8)\n                \n                // FIXME: This currently returns nil. I did not find any docs on how to encode the data properly so far.\n                print(\"Payload: \\(String(describing: content))\")\n                print(\"Error-Correction-Level: \\(desc.errorCorrectionLevel)\")\n                print(\"Symbol-Version: \\(desc.symbolVersion)\")\n            }\n        }\n    }\n})\n```\nFinally, call the image-request-handler with the previously create barcode-request:\n```swift\n// Create an image handler and use the CGImage your UIImage instance.\nguard let image = myImage.cgImage else { return }\nlet handler = VNImageRequestHandler(cgImage: image, options: [:])\n\n// Perform the barcode-request. This will call the completion-handler of the barcode-request.\nguard let _ = try? handler.perform([barcodeRequest]) else {\n    return print(\"Could not perform barcode-request!\")\n}\n```\nThat's it! Run the app on the simulator / device and detect QR-codes.\n\n## Author\nHans Knöchel ([@hansemannnn](https://twitter.com/hansemannnn))\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhansemannn%2Fios11-qr-code-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhansemannn%2Fios11-qr-code-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhansemannn%2Fios11-qr-code-example/lists"}