Swiftpack.co -  yanngodeau/SimplyNFC as Swift Package
Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
yanngodeau/SimplyNFC
Simply read and write NFC tags with iPhone
.package(url: "https://github.com/yanngodeau/SimplyNFC.git", from: "1.0.1")

SimplyNFC

Simply read and write NFC tags with iPhone (iOS 14.0+)

GitHub license Platform Swift

Installation

Swift package manager

Go to File | Swift Packages | Add Package Dependency... in Xcode and search for « SimplyNFC »

Cathage

You can use Carthage to install SimplyNFC by adding it to your Cartfile.

github "yanngodeau/SimplyNFC"

Manual

  1. Put SimplyNFC repo somewhere in your project directory.
  2. In Xcode, add SimplyNFC.xcodeproj to your project
  3. On your app's target, add the SimplyNFC framework:
    1. as an embedded binary on the General tab.
    2. as a target dependency on the Build Phases tab.

Usage

Read tag

Reading NCFNDEFMessage from tag

import SimplyNFC

let nfcManager = NFCManager()
nfcManager.read { manager in
    // Session did become active
    manager.setMessage("👀 Place iPhone near the tag to read")
} didDetect: { manager, result in
    switch result {
    case .failure:
        manager.setMessage("👎 Failed to read tag")
    case .success:
        manager.setMessage("🙌 Tag read successfully")
}

Write on tag

Writing NFCNDEFMessage on tag

import SimplyNFC

let nfcManager = NFCManager()
nfcManager.write(message: ndefMessage) { manager in
    // Session did become active
    manager.setMessage("👀 Place iPhone near the tag to be written on")
} didDetect: { manager, result in
    switch result {
    case .failure:
        manager.setMessage("👎 Failed to write tag")
    case .success:
        manager.setMessage("🙌 Tag successfully written")
}

Contribute

  • Fork it!
  • Create your feature branch: git checkout -b my-new-feature
  • Commit your changes: git commit -am 'Add some feature'
  • Push to the branch: git push origin my-new-feature
  • Submit a pull request

License

SimplyNFC is distributed under the MIT License.

Author

Based on code by @tattn

GitHub

link
Stars: 0
Last commit: 1 week ago

Ad: Job Offers

iOS Software Engineer @ Perry Street Software
Perry Street Software is Jack’d and SCRUFF. We are two of the world’s largest gay, bi, trans and queer social dating apps on iOS and Android. Our brands reach more than 20 million members worldwide so members can connect, meet and express themselves on a platform that prioritizes privacy and security. We invest heavily into SwiftUI and using Swift Packages to modularize the codebase.

Release Notes

1 week ago

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API