Search code examples
iosexponfc

Expo iOS NFC entitlement error because NDEF is disallowed


When trying to submit my Expo iOS app via EAS Submit, I get the following error:

 Asset validation failed Invalid entitlement for core nfc framework. The sdk version '17.4' and min OS version '13.4' are not compatible for the entitlement 'com.apple.developer.nfc.readersession.formats' because 'NDEF is disallowed'.

The error never changes

I have tried adding the following to my app.json individually and together to no avail:

{
  "expo": {
    "ios": {
      "entitlements": {
        "com.apple.developer.nfc.readersession.formats": ["TAG"]
      },
      "infoPlist": {
        "MinimumOSVersion": "14.0"
      }
    }
  }
}

I've also realised that the MinimumOSVersion doens't seem to change the error message.


Solution

  • You need includeNdefEntitlement: false in the config plugin options. Here's the config plugin code that uses this option:

    https://github.com/revtel/react-native-nfc-manager/blob/9301ab3f8d13115614d11ea6f1f9da22697835f1/app.plugin.js#L46

    Here's the description of the possible options in the Wiki:

    Props

    The plugin provides props for extra customization. Every time you change the props or plugins, you'll need to rebuild (and prebuild) the native app. If no extra properties are added, defaults will be used.

    • nfcPermission (string | false): Sets the iOS NFCReaderUsageDescription permission message to the Info.plist. Setting false will skip adding the permission. Defaults to Allow $(PRODUCT_NAME) to interact with nearby NFC devices (Info.plist).
    • selectIdentifiers (string[]): Sets the iOS com.apple.developer.nfc.readersession.iso7816.select-identifiers to a list of supported application IDs (Info.plist).
    • systemCodes (string[]): Sets the iOS com.apple.developer.nfc.readersession.felica.systemcodes to a user provided list of FeliCa™ system codes that the app supports (Info.plist). Each system code must be a discrete value. The wild card value (0xFF) isn't allowed.
    • includeNdefEntitlement (true | false): When explicitly set to false, removes the NDEF entitlement as a workaround to asset validation invalid entitlement bug.

    i.e. instead of this in app.json:

    {
      "expo": {
        "ios": {
          "entitlements": {
            "com.apple.developer.nfc.readersession.formats": ["TAG"]
          },
        }
      }
    }
    

    do this:

    {
      "expo": {
        "plugins": [
          [
            "react-native-nfc-manager",
            {
              "includeNdefEntitlement": false
            }
          ]
        ]
      }
    }
    

    Example from the Wiki:

    {
      "expo": {
        "plugins": [
          [
            "react-native-nfc-manager",
            {
              "nfcPermission": "Custom permission message",
              "selectIdentifiers": ["A0000002471001"],
              "systemCodes": ["8008"],
              "includeNdefEntitlement": false,
            }
          ]
        ]
      }
    }