0

My Nativescript iOS app saves some user created data using the nativescript-localstorage plugin. I want to be sure that users have a place to back-up this data.

The most straightforward option seems to be that they can include the app's data in an icloud backup (ie, icloud -> icloud Drive -> then allow the app to be backed up in the drive).

When I have used "$ tns run ios" and run the app locally on my phone, the app properly runs on my phone, but it does not appear as an option for backing up to icloud. On the icloud backup screen where apps are listed that you can choose to backup, my app does not appear.

This might be because it is just a local build, and only full releases (apps received from the app store) can be included in icloud backups, but I have not seen this confirmed anywhere.

Do I need to do anything to enable my app to be available for icloud backup?

Surenthar Pitchai
  • 1,231
  • 15
  • 18
SeanRtS
  • 1,005
  • 1
  • 13
  • 31
  • Did you enable iCloud on your app id? – Manoj Nov 29 '18 at 19:27
  • I've been running the app on my phone using "$ tns run ios" from the terminal. Where would I enable iCloud on the app id? – SeanRtS Nov 29 '18 at 19:49
  • In order to run your app you must have created an app id and provisional profile in dev portal, that's where you will find option for iCloud. Similar to how you enable push notification / in-app purchases. – Manoj Nov 29 '18 at 19:54
  • I assume you mean the dev portal of xcode. There, in the general tab--where things like provisioning profile and signing cert are listed--I do not see an option related to iCloud. Do you mean somewhere other than xcode? – SeanRtS Nov 29 '18 at 20:01
  • I meant the apple developer portal. You might be able to do it from Xocde too if you open the compiled xcode project project from platforms/ios folder, in the Capabilities section. – Manoj Nov 29 '18 at 20:05
  • I have not had to use the apple developer portal yet because I have not deployed the app. I have just been using the app locally on my device through my terminal. So it sounds like this will be an option I will have when officially deploying my app. – SeanRtS Nov 29 '18 at 20:20
  • I am now in the process of setting up the app in the portal, and trying to enable icloud support for my app. When I created the "app id" on developer.apple.com, in app services, I selected icloud and set up a cloudkit container. That app id now correctly shows icloud as being enabled, and I used that app id for the provisioning profile. But, when I test the app on testflight, the app does not show up on my phone's list of apps for enabling icloud. Other than marking enable icloud in the app id, is there something else I need to do to enable icloud support in my app? – SeanRtS Feb 15 '19 at 19:57
  • I think your entitlements file should have that feature enabled during build. – Manoj Feb 15 '19 at 19:58
  • I don't see an entitlements file in my app. How do I access that file and change it? – SeanRtS Feb 15 '19 at 20:25
  • You have to add one in your `App_Resources/iOS/[appname].entitlements`. Then add it in your `build.xcconfig` like `CODE_SIGN_ENTITLEMENTS = appname/appname.entitlements`; You may open Xcode and enable entitlements, then copy it to this directory if you are not sure about file structure. – Manoj Feb 15 '19 at 21:35
  • Thanks--sounds like there is a bunch going on there. In addition to the process of adding the file, I'll also have to get the right syntax for configuring icloud/cloudkit. Is there documentation for this? – SeanRtS Feb 15 '19 at 21:37
  • I'm getting closer, but still not working. App id and provisioning profile on apple.developer.com both show icloud enabled. I am now loading an entitlements file in platforms/ios/resources/appName.entitlements, with code that lists icloud and cloudkit. But STILL icloud support does not show up on the app. What else could I be missing? – SeanRtS Feb 19 '19 at 21:20
  • Did you make sure your final build has this entitlement file included and has iCould enabled. You could check that by opening the Xcode project in the `platforms/ios` directory. – Manoj Feb 19 '19 at 21:22
  • After I build the entitlements file shows up in both my source code and xcode at Resources/appName.entitlements. And it says stuff like: – SeanRtS Feb 19 '19 at 21:48
  • iCloud.$(CFBundleIdentifier) com.apple.developer.icloud-services CloudKit com.apple.developer.ubiquity-kvstore-identifier $(TeamIdentifierPrefix)$(CFBundleIdentifier) – SeanRtS Feb 19 '19 at 21:48
  • If you navigate to capabilities section in Xcode, do you still see iCould kit enabled? – Manoj Feb 19 '19 at 21:49
  • I do not. That is the problem. Note that I have set aps-environmentdistribution . – SeanRtS Feb 19 '19 at 21:49
  • Try adding this to your `build.xcconfig` file in your `App_Resources/iOS` - `CODE_SIGN_ENTITLEMENTS = path/to/file.entitlements`. – Manoj Feb 19 '19 at 21:51
  • I do get one error in xcode: could not find included file '.../plugins-debug.xcconfig.' in search paths'. I doubt that is related to the lack of icloud, but that is the only other thing I can see going wrong. – SeanRtS Feb 19 '19 at 21:52
  • When I entered that before I got errors. But maybe I am entering it wrong. Can you specify the proper file path description? Is it: CODE_SIGN_ENTITLEMENTS = App_Resources/iOS/AppName.entitlements? or do I start the file path reference earlier? – SeanRtS Feb 19 '19 at 21:56
  • Try `CODE_SIGN_ENTITLEMENTS = AppName/AppName.entitlements` – Manoj Feb 19 '19 at 21:57
  • Testing it out now. – SeanRtS Feb 19 '19 at 22:06
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/188710/discussion-between-9gt53ws-and-manoj). – SeanRtS Feb 19 '19 at 22:15

1 Answers1

0

I have figured out the key piece I was missing--that there are two different types of iCloud uses:

(i) the system-wide iCloud backup that happens automatically if the user turns it on (app developer does not need to take special action) and (ii) the iCloud as a cloud storage solution for certain data that you as the programmer need to configure.

For iCloud with CloudKit to show up as a specific feature of your app, this requires (ii)--and further configuration than just enabling it.

Further detail in my answer here.

SeanRtS
  • 1,005
  • 1
  • 13
  • 31