{"id":1212,"url":"https://github.com/hyperoslo/BarcodeScanner","last_synced_at":"2025-08-06T13:32:46.410Z","repository":{"id":37549345,"uuid":"54202860","full_name":"hyperoslo/BarcodeScanner","owner":"hyperoslo","description":":mag_right: A simple and beautiful barcode scanner.","archived":false,"fork":false,"pushed_at":"2024-07-29T16:11:57.000Z","size":2028,"stargazers_count":1679,"open_issues_count":24,"forks_count":387,"subscribers_count":53,"default_branch":"master","last_synced_at":"2024-08-17T14:02:40.041Z","etag":null,"topics":["barcode-scanner","camera","ios","swift","ui"],"latest_commit_sha":null,"homepage":"http://hyper.no","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hyperoslo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","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":"2016-03-18T13:25:19.000Z","updated_at":"2024-08-17T06:35:11.000Z","dependencies_parsed_at":"2024-01-11T01:08:53.088Z","dependency_job_id":"b02a4077-3117-4d6a-b687-a757a3963140","html_url":"https://github.com/hyperoslo/BarcodeScanner","commit_stats":{"total_commits":180,"total_committers":35,"mean_commits":5.142857142857143,"dds":"0.47777777777777775","last_synced_commit":"5a8a4a70c741fe5440e99849f1f66f3f199e4303"},"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hyperoslo%2FBarcodeScanner","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hyperoslo%2FBarcodeScanner/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hyperoslo%2FBarcodeScanner/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hyperoslo%2FBarcodeScanner/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hyperoslo","download_url":"https://codeload.github.com/hyperoslo/BarcodeScanner/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":215780271,"owners_count":15929791,"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":["barcode-scanner","camera","ios","swift","ui"],"created_at":"2024-01-05T20:15:41.383Z","updated_at":"2024-08-17T16:30:52.531Z","avatar_url":"https://github.com/hyperoslo.png","language":"Swift","readme":"![BarcodeScanner](https://github.com/hyperoslo/BarcodeScanner/blob/master/Art/BarcodeScannerPresentation.png)\n\n[![CI Status](http://img.shields.io/travis/hyperoslo/BarcodeScanner.svg?style=flat)](https://travis-ci.org/hyperoslo/BarcodeScanner)\n[![Version](https://img.shields.io/cocoapods/v/BarcodeScanner.svg?style=flat)](http://cocoadocs.org/docsets/BarcodeScanner)\n![Swift](https://img.shields.io/badge/%20in-swift%204.0-orange.svg)\n[![Carthage Compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)\n[![License](https://img.shields.io/cocoapods/l/BarcodeScanner.svg?style=flat)](http://cocoadocs.org/docsets/BarcodeScanner)\n[![Platform](https://img.shields.io/cocoapods/p/BarcodeScanner.svg?style=flat)](http://cocoadocs.org/docsets/BarcodeScanner)\n\n## Description\n\n**BarcodeScanner** is a simple and beautiful wrapper around the camera with\nbarcode capturing functionality and a great user experience.\n\n- [x] Barcode scanning.\n- [x] State modes: scanning, processing, unauthorized, not found.\n- [x] Handling of camera authorization status.\n- [x] Animated focus view and custom loading indicator.\n- [x] Torch mode switch.\n- [x] Customizable colors, informational and error messages.\n- [x] No external dependencies.\n- [x] [Demo project](https://github.com/hyperoslo/BarcodeScanner/tree/master/Example/BarcodeScannerExample).\n\n## Table of Contents\n\n\u003cimg src=\"https://github.com/hyperoslo/BarcodeScanner/blob/master/Art/BarcodeScannerIcon.png\" alt=\"BarcodeScanner Icon\" width=\"190\" height=\"190\" align=\"right\" /\u003e\n\n* [Usage](#usage)\n  * [Controller](#controller)\n  * [Delegates](#delegates)\n  * [Actions](#actions)\n  * [Customization](#customization)\n* [Installation](#installation)\n* [Author](#author)\n* [Contributing](#contributing)\n* [License](#license)\n\n## Usage\n\n### Controller\n\nTo start capturing just instantiate `BarcodeScannerViewController`, set needed\ndelegates and present it:\n\n```swift\nlet viewController = BarcodeScannerViewController()\nviewController.codeDelegate = self\nviewController.errorDelegate = self\nviewController.dismissalDelegate = self\n\npresent(viewController, animated: true, completion: nil)\n```\n\n\u003cdiv align=\"center\"\u003e\n\u003cimg src=\"https://github.com/hyperoslo/BarcodeScanner/blob/master/Art/ExampleScanning.png\" alt=\"BarcodeScanner scanning\" width=\"270\" height=\"480\" /\u003e\n\u003c/div\u003e\u003cbr/\u003e\n\nYou can also push `BarcodeScannerViewController` to your navigation stack:\n\n```swift\nlet viewController = BarcodeScannerViewController()\nviewController.codeDelegate = self\n\nnavigationController?.pushViewController(viewController, animated: true)\n```\n\n### Delegates\n\n**Code delegate**\n\nUse `BarcodeScannerCodeDelegate` when you want to get the captured code back.\n\n```swift\nextension ViewController: BarcodeScannerCodeDelegate {\n  func scanner(_ controller: BarcodeScannerViewController, didCaptureCode code: String, type: String) {\n    print(code)\n    controller.reset()\n  }\n}\n```\n\n**Error delegate**\n\nUse `BarcodeScannerErrorDelegate` when you want to handle session errors.\n```swift\nextension ViewController: BarcodeScannerErrorDelegate {\n  func scanner(_ controller: BarcodeScannerViewController, didReceiveError error: Error) {\n    print(error)\n  }\n}\n```\n\n**Dismissal delegate**\n\nUse `BarcodeScannerDismissalDelegate` to handle \"Close button\" tap.\n**Please note** that `BarcodeScannerViewController` doesn't dismiss itself if\nit was presented initially.\n\n```swift\nextension ViewController: BarcodeScannerDismissalDelegate {\n  func scannerDidDismiss(_ controller: BarcodeScannerViewController) {\n    controller.dismiss(animated: true, completion: nil)\n  }\n}\n```\n\n### Actions\n\nWhen the code is captured `BarcodeScannerViewController` switches to the processing\nmode:\n\n\u003cdiv align=\"center\"\u003e\n\u003cimg src=\"https://github.com/hyperoslo/BarcodeScanner/blob/master/Art/ExampleLoading.png\" alt=\"BarcodeScanner loading\" width=\"270\" height=\"480\" /\u003e\n\u003c/div\u003e\u003cbr/\u003e\n\nWhile the user sees a nice loading animation you can perform some\nbackground task, for example make a network request to fetch product info based\non the code. When the task is done you have 3 options to proceed:\n\n1. Dismiss `BarcodeScannerViewController` and show your results.\n\n```swift\nfunc scanner(_ controller: BarcodeScannerViewController, didCaptureCode code: String, type: String) {\n // Code processing\n controller.dismiss(animated: true, completion: nil)\n}\n```\n\n2. Show an error message and switch back to the scanning mode (for example,\nwhen there is no product found with a given barcode in your database):\n\n\u003cdiv align=\"center\"\u003e\n\u003cimg src=\"https://github.com/hyperoslo/BarcodeScanner/blob/master/Art/ExampleError.png\" alt=\"BarcodeScanner error\" width=\"270\" height=\"480\" /\u003e\n\u003c/div\u003e\u003cbr/\u003e\n\n```swift\nfunc scanner(_ controller: BarcodeScannerViewController, didCaptureCode code: String, type: String) {\n // Code processing\n controller.resetWithError(message: \"Error message\")\n // If message is not provided the default message will be used instead.\n}\n```\n\n3. Reset the controller to the scanning mode (with or without animation):\n\n ```swift\n func scanner(_ controller: BarcodeScannerViewController, didCaptureCode code: String, type: String) {\n   // Code processing\n   controller.reset(animated: true)\n }\n ```\n\nIf you want to do continuous barcode scanning just set the `isOneTimeSearch`\nproperty on your `BarcodeScannerViewController` instance to `false`.\n\n### Customization\n\nWe styled **BarcodeScanner** to make it look nice, but you can always use public\nproperties or inheritance to customize its appearance.\n\n**Header**\n\n```swift\nlet viewController = BarcodeScannerViewController()\nviewController.headerViewController.titleLabel.text = \"Scan barcode\"\nviewController.headerViewController.closeButton.tintColor = .red\n```\n\n**Please note** that `HeaderViewController` is visible only when\n`BarcodeScannerViewController` is being presented.\n\n**Footer and messages**\n\n```swift\nlet viewController = BarcodeScannerViewController()\nviewController.messageViewController.regularTintColor = .black\nviewController.messageViewController.errorTintColor = .red\nviewController.messageViewController.textLabel.textColor = .black\n```\n\n**Camera**\n```swift\nlet viewController = BarcodeScannerViewController()\n// Change focus view style\nviewController.cameraViewController.barCodeFocusViewType = .animated\n// Show camera position button\nviewController.cameraViewController.showsCameraButton = true\n// Set the initial camera position\nviewController.cameraViewController.initialCameraPosition = .front // Default is .back\n// Set settings button text\nlet title = NSAttributedString(\n  string: \"Settings\",\n  attributes: [.font: UIFont.boldSystemFont(ofSize: 17), .foregroundColor : UIColor.white]\n)\nviewController.cameraViewController.settingButton.setAttributedTitle(title, for: UIControlState())\n```\n\n**Metadata**\n```swift\n// Add extra metadata object type\nlet viewController = BarcodeScannerViewController()\nviewController.metadata.append(AVMetadataObject.ObjectType.qr)\n```\n\n## Installation\n\n**BarcodeScanner** is available through [CocoaPods](http://cocoapods.org). To install\nit, simply add the following line to your Podfile:\n\n```ruby\npod 'BarcodeScanner'\n```\n\nDon't forget to set a `Privacy - Camera Usage Description` in your Info.plist file, else the app will crash with a SIGBART. \n\nIn order to quickly try the demo project of a **BarcodeScanner** just run\n`pod try BarcodeScanner` in your terminal.\n\n**BarcodeScanner** is also available through [Carthage](https://github.com/Carthage/Carthage).\nTo install just write into your Cartfile:\n\n```ruby\ngithub \"hyperoslo/BarcodeScanner\"\n```\n\nTo install **BarcodeScanner** manually just download and drop `Sources` and\n`Images` folders in your project.\n\n## Author\n\nHyper Interaktiv AS, ios@hyper.no\n\n## Contributing\n\nWe would love you to contribute to **BarcodeScanner**, check the [CONTRIBUTING](https://github.com/hyperoslo/BarcodeScanner/blob/master/CONTRIBUTING.md) file for more info.\n\n## License\n\n**BarcodeScanner** is available under the MIT license. See the [LICENSE](https://github.com/hyperoslo/BarcodeScanner/blob/master/LICENSE.md) file for more info.\n","funding_links":[],"categories":["Hardware","Libs","Scan","Hardware [🔝](#readme)"],"sub_categories":["Camera","Hardware","Other free courses","RSS"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhyperoslo%2FBarcodeScanner","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhyperoslo%2FBarcodeScanner","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhyperoslo%2FBarcodeScanner/lists"}