1

I have been struggling to get my iOS app to enable iCloud.

I have followed documentation and have switched on iCloud with CloudKit in my project in Xcode.

But, when I then upload the app to App Store Connect from Xcode, iCloud is not there. It does not show up under "Capabilities" and in using the app through TestFlight, iCloud is not enabled.

Is there something special I need to do? Using Xcode version 10.1 + Mac OS High Sierra 10.13.

Note: there is a bunch of detail below. If you want to skip the detail, the summary is that I have followed the straight forward route to enabling iCloud, but it is not yet showing up in App Store Connect or on device through TestFlight.


Steps:

I have followed documentation and tried a few solutions like here and here.

1) I open my project in xcode.

2) In the xcode Capabilities pane, I switch on iCloud, check CloudKit, and use default container (a container named: "iCloud.com.[bundle identifier]").

3) At developer.apple.com, I verify that the app Id I am using has automatically enabled iCloud and CloudKit (it shows as green there).

4) At developer.apple.com, create a provisioning profile using that app id. iCloud is listed among the "Enabled Services" for this profile.

5) Back in xcode, in the General pane, turn off automatically manage signing and select this provisioning profile. If I select "automatically manage signing", it uses an "iPhone Developer" account for the signing certificate, which seems incorrect; when I do manual signing and select the updated prov profile, the Signing Certificate correctly reads "Iphone Distribution: [team name]"

6) Archive app: product -> archive. (I have double-checked here that iCloud remains selected in the Capabilities pane, without error)

7) Upload app: window -> organizer -> select archive, click distribute app, and take it from there.

Result: Build gets uploaded to App Store Connect successfully, but no iCloud support anywhere to be seen.

What else do I need to do?

NOTES:

When I archive the app, the entitlements file (listed under AppName -> AppName -> AppName.entitlements), includes this:

<dict>
    <key>aps-environment</key>
    <string>development</string>
    <key>com.apple.developer.icloud-container-identifiers</key>
    <array>
        <string>iCloud.$(CFBundleIdentifier)</string>
    </array>
    <key>com.apple.developer.icloud-services</key>
    <array>
        <string>CloudKit</string>
    </array>
    <key>com.apple.developer.ubiquity-kvstore-identifier</key>
    <string>$(TeamIdentifierPrefix)$(CFBundleIdentifier)</string>
</dict>
</plist>

The aps-environment says "development". I have tried archiving and uploading this way, and it hasn't worked to enable icloud in App Store Connect. I have also tried manually switching this to "production" and archiving/uploading--but the result was the same there too.

--The underlying app is made with Nativescript, but I don't think that should matter for this stage, as I am uploading through xcode. (I have already gone through Nativescript info on this.)

--when I go into cloudkit dashboard, the Container says "in development". I haven't seen a way to change that without error

SeanRtS
  • 1,005
  • 1
  • 13
  • 31

2 Answers2

0

It's a very long story, therefore, it's hard to follow and get the whole picture, but base on your comments...

It seems that you are missing the console Cloud activation somehow. I guess you may be mixing the development and distribution profiles.

My advice now that you're moving to the App Store Connect is move EVERYTHING to Production environment and if you haven't, update the profiles/provisionings.

I quote

On the cloud kit dashboard, each container will have a blue box for the Development environment and green box for the Production environment.

You can create and delete record types on the fly in the (blue) Development environment. But once you deploy to the (green) Production environment, that schema becomes permanent in that container. You can't delete record types from the (green) Production environment.

Deleting is harsh...

Try this approach and let me know if I hit the spot! ;) If I didn't, don't vote my down just jet lol, comment and I'll try to help you further.

This tutorial is pretty well known but I consider it's great for iCloud first comers, check it out if you haven't: https://www.raywenderlich.com/1000-cloudkit-tutorial-getting-started

Good luck!

Helen Wood
  • 1,872
  • 2
  • 26
  • 41
  • Thank you. My icloud containers seem stuck "in development" (they are blue in the cloudkit dashboard home page). I've tried going into the container and clicking "deploy to production" but that doesn't do anything. Any other way to move the container into the green Production environment? The app id and profile I set up with iCloud enabled are both set to production. – SeanRtS Feb 24 '19 at 15:49
  • As I said, try creating a new container for production, leave the development one there alone... Let me know if that did the trick. – Helen Wood Feb 24 '19 at 16:01
  • Thanks--but that's what I am missing. How do I create a new container for production? I created an app id and prov profile for production (clicking for app store distribution when creating both), and enabled icloud there. Then xcode created the containers, and said they were "in development" mode. Is there a different way I should be creating the containers? – SeanRtS Feb 24 '19 at 16:32
  • BTW, thanks for the tutorial. I hadn't seen that before and will definitely take a look. – SeanRtS Feb 24 '19 at 16:32
  • I have reviewed the tutorial. The tutorial seems to describe the way to set up the cloudkit container in a way that matches what I have done already. But I do not see where it discusses transferring a development container into a production container. (I see it sets up specific configs within a container, but not shifting the whole thing to production.) – SeanRtS Feb 26 '19 at 18:46
  • In any event, I think the issue is probably not specific to the icloud container setup. I think it is a general capabilities issue. I activate the capabilities through xcode (like I describe above), and they appear there. But then they don't appear when I view the app in app store connect. – SeanRtS Feb 26 '19 at 18:47
  • If you enable icloud through xcode, does it automatically "work"? Or are you REQUIRED to manually go into the icloud containers and do app-specific setup work? Maybe the issue for me is that enabling it is just the first step, and configuration is then required. I had been told it automatically "works", but is that wrong? – SeanRtS Feb 26 '19 at 21:25
  • Thanks, but I have experimented in trying several different apps and creating several different containers. Same result each time. – SeanRtS Feb 27 '19 at 14:54
0

I've figured out the essential issue here: I was confusing what is, basically, two different iClouds (or at least two very different ways to use iCloud as a developer).

This will be obvious to many/most people familiar with iOS programming, but it was the key point I did not grasp.

Without this information, I was thrown off by some people saying iCloud just "automatically works", while others would go into depth about the need to do configuration. They both were right--just talking about different things.

So this is what I did not grasp before: These are the two different uses of iCloud from the developer perspective:

1) Automatic, backup iCloud. This is the system-wide feature, that allows users to back up data from their device. Users turn it on through turning on “iCloud Backup” (settings --> apple id --> iCloud). Once on, the device automatically backs up the user's data regularly. This feature will automatically back up data from your app that is included in the app/Documents directory. Further info here.

See here for details on preventing certain data from being backed up if you want.

Other than putting data you want backed up in the system wide back up in the documents director, there is nothing you as an app developer need to do. You do not even need to enable iCloud through Xcode (I think--though others please correct me if I am wrong).

This will not load data from iCloud onto your app when the app is loaded. Rather, it saves a backup (of your app data and the other data on the user's phone)--the main benefit of which is that if the user loses their device they can recover that data on a different device.

2) App specific cloud storage through iCloud. This affirmatively does not happen automatically, and requires meaningful configuration.

This is where you can use iCloud like a backend cloud solution. For example, you can send specific data to iCloud when that data is created, and then later get that data from iCloud onto the app when the user loads the app (instead of storing that data locally on the user's device).

This is where CloudKit comes in.

To enable this, you need to generate the proper entitlements file--such as enabling iCloud w/ CloudKit on Xcode, and being sure the app id and provisioning profile confirm that CloudKit is enabled. For a bit more detail, see my steps 1 through 7 in my question. This should work to get things "enabled".

But that is just the first piece, you then need to get things "configured". To do this, you likely have to do some configuration of the container that CloudKit generates for your app, and add code specific to the backend process in your app. There is some good info in the tutorial linked in the prior answer.

Thanks to those who gave info on this, including Apple Developer Technical Support.

SeanRtS
  • 1,005
  • 1
  • 13
  • 31
  • Thank you, this really helps. Do you have any idea how to prevent in NativeScript a directory from being automatically backed up to iCloud? – Ori Idan Oct 13 '19 at 11:29
  • Thanks. I see elsewhere on stack overflow that you have had a discussion on doing this by setting the NSURLIsExcludedFromBackupKey. I have not implemented that, so am not able to add to that discussion at this point. Perhaps ask on the nativescript slack? Implementing obj C / swift code from Apple docs into nativescript is one of the parts of nativescript that could use more tutorials and documentation. – SeanRtS Oct 14 '19 at 13:46