Always Getting Error while reading NFC

I am following this code https://developer.apple.com/documentation/corenfc/building_an_nfc_tag-reader_app

to implement a simple scanner for NFC. Now whenever I scan I am always getting <NSXPCConnection: 0x3036981e0> connection to service with pid 60 named com.apple.nfcd.service.corenfc: Exception caught during decoding of received selector didDetectExternalReaderWithNotification:, dropping incoming message. Exception: Exception while decoding argument 0 (#2 of invocation): Exception: decodeObjectForKey: class "NFFieldNotificationECP1_0" not loaded or does not exist>. this error. It always calls this function

func readerSession(_ session: NFCNDEFReaderSession, didInvalidateWithError error: Error)