Forum Xamarin.iOS

Cannot get iCloud to work in Xamarin.Mac app

TommyOvesenTommyOvesen USMember ✭✭

My Mac app need to save some values to the iCloud key-value store, however I cannot get it to work.

When saving data I use this code:

                   var store = NSUbiquitousKeyValueStore.DefaultStore;
                    store.SetString(key, val);
                    store.Synchronize();

And for reading:

                var store = NSUbiquitousKeyValueStore.DefaultStore;
                var val = store.GetString(key);
                return val;

The saving part is called without any error, and the reading is always returning null. I am sure the provisioning profile is correctly set up, and the entitlements also. Is there anything preventing me from testing iCloud on my Mac in the debugger? Any ideas?

Thanks.

Tagged:

Best Answer

  • TommyOvesenTommyOvesen USMember ✭✭
    Accepted Answer

    I just asked in case there was something different/obvious with regards to Mac apps I had missed.
    Anyway, I finally got it working. The problem was that in the projects Mac signing-options, there is no Entitlement selected in the default projects. As soon as I added the Entitlements.plist file it worked.

Answers

  • ChrisHamonsChrisHamons USForum Administrator, Xamarin Team Xamurai

    How can you be certain that - "I am sure the provisioning profile is correctly set up, and the entitlements also"?

    It certainly sounds like you have entitlement / signing / sandbox issues.

    I don't believe the debugger would have any affect.

  • ChrisHamonsChrisHamons USForum Administrator, Xamarin Team Xamurai

    I would consider starting with a trivial objective-c version that does that, and get it working with entitlements / signing. Then compare that with yours and see where you have it misconfigured.

  • TommyOvesenTommyOvesen USMember ✭✭

    Thanks. I wish you were right that I´m having entitlement / signing / sandbox issues. I just tested as you suggested with a simple XCode/swift solution, and everything works as expected. Also I had no problem with iCloud in a IOS app using Xamarin, only my Mac project is not working.

  • ChrisHamonsChrisHamons USForum Administrator, Xamarin Team Xamurai

    Have you compared the info.plist between your working ObjC and C# mac samples? Are there any differences? Are you signing with the same key / entitlement.

    Since you haven't provided much information (or a sample showing the issue at hand), there is very little people can do on the forum beyond guess.

  • TommyOvesenTommyOvesen USMember ✭✭
    Accepted Answer

    I just asked in case there was something different/obvious with regards to Mac apps I had missed.
    Anyway, I finally got it working. The problem was that in the projects Mac signing-options, there is no Entitlement selected in the default projects. As soon as I added the Entitlements.plist file it worked.

Sign In or Register to comment.