When running the [await SecureStorage. SetAsync] command in the MAUI IOS simulator, an error is reported: Error adding record: MissingEntity

hm w 11 Reputation points
2022-10-21T03:09:00.747+00:00

An error is reported when running the [await SecureStorage. SetAsync] command in the MAUI IOS simulator. The error is [Error adding record: MissingEntitlement]. Is this not a permission in IOS? How should it be set?

.NET MAUI
.NET MAUI
A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
2,207 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Wenyan Zhang (Shanghai Wicresoft Co,.Ltd.) 23,476 Reputation points Microsoft Vendor
    2022-10-24T04:37:15.193+00:00

    Hello @hm w ,

    "Error adding record: Missing Entitlement" means that there is not an Entitlements.plist file under Platforms/iOS folder. When using Secure Storage and developing on the iOS simulator, you should enable the Keychain entitlement and add a keychain access group for the application's bundle identifier.
    You could add a new XML file named Entitlements.plist to the Platforms\iOS\ folder of your app project. Then add the following XML to the 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>keychain-access-groups</key>  
          <array>  
                <string>$(AppIdentifierPrefix)xxx</string>  
          </array>  
    </dict>  
    </plist>  
    

    Note: xxx means the Bundle Identifier of your iOS project, you can open the info.plist file and copy the value.

    For more details about Entitlements.plist, you can refer to Entitlements and capabilities - .NET MAUI | Microsoft Learn

    Best Regards,
    Wenyan Zhang


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    3 people found this answer helpful.