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 -> []
            }
        }
    }
}

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>

I have same problem!

We had the same problem, but only after iOS 17.4 - 16.x worked. We then added all AIDs of Applications on the smartcard except for the "main" one. It seems like newer iOS versions get a problem if you switch the application on the card, and the AID is not contained in Info.plist.

Hope it helps.

Correction - not "except" for the main one. but in addition to the main one. Sorry no native ;)

NFCTagReaderSession - Missing required entitlement
 
 
Q