2
votes

I'm trying to include iCloud key-value storage support to my Xamarin.iOS (v4.0.30319) app in Visual Studio 2013 (Xcode 7.2.1 on Mac), but constantly getting:

error MT1019: Your application has entitlements not supported by your current provisioning profile and could not be installed on the device 'My iPhone 4'. Please check the iOS Device Log for more detailed information (error: 0xe8008016).

By the way there are no logs on device, at least xCode won't show any.

I have another app written in native objective C in Xcode, it also has iCloud support and it works ok. So I've done the same things:

  1. created iCloud container on developer.apple.com with name "iCloud.[my team id].[my bundle id]" (I used exact values, without macro)
  2. created app id for [my bundle id] on developer.apple.com with enabled iCloud for container "iCloud.[my team id].[my bundle id]"
  3. created development provisioning profile
  4. installed it in Xcode.
  5. selected it in Visual Studio in "iOS Bundle Signing"
  6. edited entitlements as written here :
    <?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>com.apple.developer.ubiquity-kvstore-identifier</key>
        <string>iCloud.[my team id].[my bundle id]</string>
        <key>com.apple.developer.ubiquity-container-identifiers</key>
        <array>
            <string>iCloud.[my team id].[my bundle id]</string>
        </array>
    </dict>
    </plist>

After that Xamarin doesn't want to install my app on device. I've changed name of container, removed com.apple.developer.ubiquity-container-identifiers from entitlements and returned it (always deleting all provisioning profile, redownloading to xcode, relaunching visual studio, cleaning solution, removing profiles on device, uninstalling existing app). Only when I remove com.apple.developer.ubiquity-kvstore-identifier and com.apple.developer.ubiquity-container-identifiers from entitlements Xamarin installs app to device. But obviously NSUbiquitousKeyValueStore does not work. What's wrong in my setup?

1

1 Answers

2
votes

I even tried to get entitlements from my other xcode project, after setting Capabilities->Cloud "on". It produces plist with only com.apple.developer.ubiquity-kvstore-identifier value with default value $(AppIdentifierPrefix)[my bundle id].

And when I was almost ready to go to sleep, app is launched! Final Entitlements (no "iCloud." previx, and no other keys):

<plist version="1.0">
<dict>
    <key>com.apple.developer.ubiquity-kvstore-identifier</key>
    <string>[my team id].*</string>

    <key>com.apple.developer.ubiquity-container-identifiers</key>
    <array>
      <string>iCloud.[my team id].[my bundle id]</string>
    </array>

    <key>com.apple.developer.icloud-container-identifiers</key>
    <array>
      <string>iCloud.[my team id].[my bundle id]</string>
    </array> 

</dict>
</plist>

The trick was simply open myapp.mobileprovision file and see what does it suggest.

It does work and yet NSFileManager.DefaultManager.GetUrlForUbiquityContainer(null) returns null and NSFileManager.DefaultManager.UbiquityIdentityToken is null also. So there is no way to see if iCloud on or off: it always saves data and even shows it (until reinstall of app). But if iCloud was on data persists after reinstall.

UPDATE

IMPORTANT NOTICE: NSFileManager.DefaultManager.GetUrlForUbiquityContainer(null) returns null in DEBUG, adHoc version returned valid token and path.

APPLE hates developers! I've spent 3 days to make cloud work, all because of lack of docs, existing are outdated.