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.
3,486 questions
{count} votes

3 answers

Sort by: Most helpful
  1. Wenyan Zhang (Shanghai Wicresoft Co,.Ltd.) 31,166 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.

    7 people found this answer helpful.

  2. Thabo mashaba 10 Reputation points
    2024-04-16T09:53:14.43+00:00

    To resolve the "MissingEntitlement" error when using SecureStorage in the MAUI iOS simulator, ensure that your app's capabilities are correctly configured by enabling the "Keychain Sharing" capability in your project settings. Additionally, verify that your app's entitlements file includes the necessary entitlements for accessing the SecureStorage and that your App ID in the Apple Developer portal is configured appropriately. Finally, make sure your provisioning profile contains the correct entitlements for the capabilities you've enabled. After adjusting these settings, rebuild your app and test it again in the iOS simulator to verify that the error has been resolved.

    1 person found this answer helpful.
    0 comments No comments

  3. Samira Mahdavi 0 Reputation points
    2024-01-29T08:19:04.76+00:00

    This solution worked for me.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.