[NFCReaderSession readingAvailable]: unrecognized selector

I have an iPhone 8 running iOS 12.2 and iPhone 8 Max running iOS 12 and in both cases, calling the method NFCReaderSession.readingAvailable results in a crash with the following message [NFCReaderSession readingAvailable]: unrecognized selector sent to class. This method is supposed to be available in iOS 11. I have tested this on my iPhone 6s running iOS 12.4 and the method returns false, as it should because NFC isn’t supported on an iPhone 6s. I have tested on my iPhone Xs and the method returns true, as it should. I’m trying to narrow down if this is bug with a specific phone version with iOS 8 and iOS 12? Thanks for any help!

Replies

Did you add the key in info plist for : Privacy - NFC Scan Usage Description

Yes, I have added that key.

Did you do an option-clean-build Folder ?

Yes, did that too.

I believe that this is a bug in the availability annotations in the SDK. If you go back to the iOS 12.4 SDK, you’ll see that

NFCReaderSession
is available but there’s no
readingAvailable
property. The first SDK in which that property shows up is the iOS 13 SDK. That strongly implies that the property was added in iOS 13. If so, it should have an availability annotation along those lines, but it does not, meaning it inherits it’s availability from the
NFCReaderSession
class, that is, it’s considered available since iOS 11.

Please file a bug against the SDK, and post your bug number, just for the record.

It should be easy to work around this: Simply avoid using the property on older systems.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

Thanks for the response @eskimo! One follow up question is this, how come it works on an iPhone 6s running iOS 12.4? The call to readingAvailable returns false and NFC is not supported on that hardware. I wonder if there is a bug with iOS 12 with devices that can support NFC?


Here is a link to the radar I created. Thanks!


https://feedbackassistant.apple.com/feedback/7471651

One follow up question is this, how come it works on an iPhone 6s running iOS 12.4?

I don’t know for sure. It’s possible that this method was added as a private method in 12.4, and thus the call works on all 12.4 devices even though it’s not in the public iOS 12.4 SDK.

Here is a link to the radar I created.

Much appreciated.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"