NFCTagReaderSession - Missing required entitlement

Hi there,

I am using Core NFC and I established the connection with the card, (it means that the info.plist is correct and the entitlement should be correct as well). The app detects the card, but after sending the command 'tag.sendCommand()' I receive this message:

[CoreNFC] -[NFCTagReaderSession transceive:tagUpdate:error:]:879 Error Domain=NFCError Code=2 "Missing required entitlement" UserInfo={NSLocalizedDescription=Missing required entitlement}

So, what is missing or what am I doing wrong?

Here is the code:

func tagReaderSession(_ session: NFCTagReaderSession, didDetect tags: [NFCTag]) {

    guard !tags.isEmpty else { return }
    
    let hexString = //...

    if case let .iso7816(tag) = tags[0] {
        session.connect(to: tags[0]) { error in
            if let error = error {
                print("Error: \(error.localizedDescription)")
                return
            }
                            
            let apdu = hexString.convertToAPDU()            
            tag.sendCommand(apdu: apdu) { (response: Data, sw1: UInt8, sw2: UInt8, error: Error?)  in
                // -> here is when the error appears, in the completion 
                print([UInt8](response)) // print -> []
            }
        }
    }
}
Post not yet marked as solved Up vote post of dyaremyshyn Down vote post of dyaremyshyn
1k views

Replies

Have you configured the Near Field Communication Tag Reading capability in Xcode?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Yes, I configured the NFC capability.

Here is my entitlements file:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>com.apple.developer.nfc.readersession.formats</key>
    <array>
        <string>NDEF</string>
        <string>TAG</string>
    </array>
</dict>
</plist>

And my info.plist:

<key>com.apple.developer.nfc.readersession.iso7816.select-identifiers</key>
<array>
        <string>315449432E494341</string>
</array>

<key>NFCReaderUsageDescription</key>
<string>NFC reason</string>
  • did anyone have a idea how to solve this ? @dyaremyshyn i know its a little late but did you solve it ?

Add a Comment