Essentials: SecureStorage requires Entitlements.plist update for iOS simulator

Created on 11 May 2018  路  8Comments  路  Source: xamarin/Essentials

Description

This is probably more of a documentation update than anything, but I was recently getting an exception when using SecureStorage on the iOS simulator. The same usage worked fine on an actual device. Happy to make the doc updates, if we agree.

Steps to Reproduce

  1. Call SecureStorage.SetAsync("key", "value"); on the iOS simulator

Expected Behavior

No exceptions.

Actual Behavior

Received the following error:

System.Exception: Error adding record: Param occurred

Basic Information

That exception comes back to this line:
https://github.com/xamarin/Essentials/blob/8056f53f50a5c995606de2a4a835d3db5177e8d2/Xamarin.Essentials/SecureStorage/SecureStorage.ios.cs#L91

After some research, I found this forum post: https://forums.xamarin.com/discussion/comment/259478/#Comment_259478

Turns out that for the simulator, you need to KeyChain access in the Entitlements.plist, and also need to use that plist for app signing.

  • Version with issue: 0.6.0-preview
  • Last known good version: ?
  • IDE: VS 2017
  • Platform Target Frameworks:

    • iOS: iOS 11.3 (15E217)

  • Nuget Packages: 0.6.0-preview
  • Affected Devices: iOS Simulator

Reproduction Link

I also noticed that iOS unit tests are intentionally skipped on simulated devices:
https://github.com/xamarin/Essentials/blob/8056f53f50a5c995606de2a4a835d3db5177e8d2/DeviceTests/DeviceTests.Shared/SecureStorage_Tests.cs#L24

I was able to fix this, and have a PR ready to go. I must admit that I am not entirely sure if the signing will pose some other issue, but so far things have worked in my testing.

bug in-progress

Most helpful comment

@Anandride Same probleme here, it is quite troublesome. This should work for the iPhone Simulator out of the box.

BTW the real problem is. As soon as you need Entitlements.plist for the Simulator like you do when using SecureStorage you need an Apple Developer account. I do not see the reason why I sould throw money to a company only to develop an application with no timefrate to add it to the appstore anytime soon.

All 8 comments

Good catch. Looks like not on device as that was our test.

I have documented some changes here: https://github.com/MicrosoftDocs/xamarin-docs/pull/255 can you review this for me too.

Hey guys, what version should I look for this in? Also running into this issue.

Thanks!

Hey @Osmosis311 - In the current release, you should be able to update your Entitlements.plist based on the updated docs by @jamesmontemagno, here: https://docs.microsoft.com/xamarin/essentials/secure-storage?context=xamarin%2Fandroid&tabs=ios

Let me know if that doesn't work for you. The update that I made in the corresponding PR, was to enable the unit tests on the simulator by doing the same thing.

There is no changes to the library actually. It is documented already on how to set it up. We just updated the samples and unit tests :)

When I set Custom Entitlements to Entitlements.plist, under iOS Bundle Signing...

I'm getting a build error: Could not find any available provisioning profiles for iOS.

How do I fix this? I have seen adding of provisioning profiles is used when we want to deploy it on real devices not simulators.

You have to setup a provisioning profile and cert for your app @priyanka-kondapuram. That will solve your issue.

i have to run application on simulator , so what the need of provisioning profiles. but getting same issue like @priyanka-kondapuram

@Anandride Same probleme here, it is quite troublesome. This should work for the iPhone Simulator out of the box.

BTW the real problem is. As soon as you need Entitlements.plist for the Simulator like you do when using SecureStorage you need an Apple Developer account. I do not see the reason why I sould throw money to a company only to develop an application with no timefrate to add it to the appstore anytime soon.

Was this page helpful?
0 / 5 - 0 ratings