I love to store my settings via Xamarin.Essentials. But for some settings I would like to share these, via a cloud. I don’t want to setup a cloud where I have to store the user data (privacy). So I decided to use iCloud.
Microsoft have a documentation how to do this. For me the Key-Value storage is enough. There is a 64kbit limit for all settings together, but thats OK in my case. In my tests I could store the radio stations, which have the user selected via json (over 50 stations).
In this post I want to share the pitfalls and how it is working like in this example video. In my tests the sync is about 1-5 seconds. The video is speed x2:
First of all we have to set our Entitlements for our app at developer.apple.com in Account > Certificates, Identifiers & Profiles > Identifiers > YourApp.
If you made changes here, you have to recreate all Provisioning profiles which you use!
Here I enabled iCloud and setup the Container. After this I changed my entitlements in macOS & iOS project:
But there is pitfall one…
Visual Studio adds the container to the Entitlements.plist, but this would break the build with “wrong entitlements” error.
With a look at the file we see:
<key>com.apple.developer.icloud-container-identifiers</key> <array> <string>iCloud.de.suplanus.Cuterdio</string> </array>
We have to remove this. The only thing we need is:
The entitlements should now look like this… Crazy. Attention: If you made changes here, it’s possible that Visual Studio rewrite “wrong” entitlements to the file:
ApplicationVerificationFailed: Failed to verify code signature of /var/installd/Library/Caches/com.apple.mobile.installd.staging/temp.JF1tMP/extracted/Payload/Cuterdio.iOS.app : 0xe8008016 (The executable was signed with invalid entitlements.)
Git is here my friend and shows me the changes.
After try & error… it works… Great. I created a PR from the dev-branch. After merging, App Center builds it and push it to Apple Testflight… But I got this error in Distribute:
ERROR ITMS-90046: “Invalid Code Signing Entitlements. Your application bundle’s signature contains code signing entitlements that are not supported on iOS. Specifically, value ‘Development’ for key ‘com.apple.developer.icloud-container-environment’ in ‘Payload/Cuterdio.iOS.app/Cuterdio.iOS’ is not supported.”
Oh no… what is now the problem? I don’t know… but I found the problem in a GitHub Issue.
So we have to set the environment in our Entitlements.plist manually for App Cen