Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/el-hoshino/metadatascanner
A MetadataScanner view for SwiftUI
https://github.com/el-hoshino/metadatascanner
Last synced: 28 days ago
JSON representation
A MetadataScanner view for SwiftUI
- Host: GitHub
- URL: https://github.com/el-hoshino/metadatascanner
- Owner: el-hoshino
- License: mit
- Created: 2021-03-17T17:33:04.000Z (almost 4 years ago)
- Default Branch: develop
- Last Pushed: 2021-03-22T07:00:57.000Z (almost 4 years ago)
- Last Synced: 2024-12-07T18:45:20.700Z (about 1 month ago)
- Language: Swift
- Size: 1.7 MB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# MetadataScanner
MetadataScanner is a metadata scanning library built for SwiftUI apps. It provides a `Button`-like view component to make scanning view easy to implement.
## Requirements
- iOS 14.0+
- Xcode 12.4+
- Swift 5.3+## Usage
You can use `MetadataScanner` just like any other `View` component inside a `body: some View` property in your projects.
One thing you need to notice is that the initializer may return `nil` if no available camera found. You can replace it with any placeholder view using `if let else` statement ([check the example](Example/MetadataScannerExample/ContentView.swift)), or if you don't need a placeholder you can also just ignore it, and SwiftUI will handle it as there is no view at all.
## Example
```swift
MetadataScanner(videoGravity: .resizeAspectFill,
objectTypes: [.qr],
scans: true,
onScannedObjectUpdate: { print($0) })
```You may find a more real-situation example project in [Example](Example) path, and it looks like below:
![Example App Screenshots](README_Resource/example_app.gif)
## Installation
### Use SwiftPM (in Xcode)
1. Xcode > File > Swift Packages > Add Package Dependency
2. Add https://github.com/el-hoshino/MetadataScanner.git
3. Select "Up to Next Major" with "0.1.0"### Use SwiftPM (using Package.swift)
1. Create a `Package.swift` file.
2. Add dependencies like below:
```swift
// swift-tools-version:5.3
// The swift-tools-version declares the minimum version of Swift required to build this package.import PackageDescription
let package = Package(
name: "MyAwsomeProject",
dependencies: [
.package(url: "https://github.com/el-hoshino/MetadataScanner.git", from: "0.1.0")
],
targets: [
.target(name: "MyAwsomeProject", dependencies: ["MetadataScanner"])
]
)