apache / apache/cordova-plugin-file
iOS cordova.file.syncedDataDirectory writable/readable but files aren't synced between devices
- Dominant language
- JavaScript
- Stars
- 744
- Forks
- 754
- Avg merge
- 3d 4h
- Merged PRs (30d)
- 1
Description
# Bug Report
Hi Cordova team,
I'm not sure if it's a bug or if I misunderstood [the documentation](https://cordova.apache.org/docs/en/11.x/reference/cordova-plugin-file/#ios-file-system-layout) about `cordova-plugin-file` so any help/advices would be very appreciated (I'm targeting/working on an **iOS webapp**).
## Problem
I'de like to read/write file in a synced folder automatically synced with iCloud. The goal is to be able of writing the file from **device1** and reading the same file from **device2** (and vice-versa). Files wouldn't have to be accessible from the user, only from the app (private files such as user preferences, user infos, etc).
### What is expected to happen?
From the [doc](https://cordova.apache.org/docs/en/11.x/reference/cordova-plugin-file/#ios-file-system-layout), I understood that files saved into the `cordova.file.syncedDataDirectory` folder would be automatically synced. The value of the **syncedDataDirectory** key returns: `file:///var/mobile/Containers/Data/Application/01234-56789/Library/Cloud/`
### What does actually happen?
I can write/read file from this folder from the **same device**, everything works as expected.
However, files are not synced at all between devices.
In a first time, I just like to get a confirmation from developers of this plugin about the goal of this `syncedDataDirectory`?
What do you mean by "_Holds app-specific files that should be synced (e.g. to iCloud)_"? Do you confirm that files written on **device1** could be read from **device2**?
## Information
Of course all iOS devices on which I did test are **connected** to the same **iCloud account**, iCloud **is enabled** in device settings, iCloud Drive **is enabled** (don't know if it has anything to do with), iCloud for my app **is enabled** too.
### Command or Code
I have added to my `config.xml` (from [the doc](https://cordova.apache.org/docs/en/11.x/reference/cordova-plugin-file/#configuring-the-plugin-optional) but I'm not sure it would be necessary in my case):
```
```
I also tried to add **iCloud Capabilities** from Xcode (from TARGET > SIGNING & CAPABILITIES).
I have created a new iCloud container `iCloud.com.company.container-name`.
I have checked the box **iCloud Documents** in my **iCloud Capabilities**.
I have upgraded my app build version number (such as explained in the [Apple Doc](https://developer.apple.com/documentation/uikit/documents_data_and_pasteboard/synchronizing_documents_in_the_icloud_environment#3743498) about `NSUbiquitousContainers`).
I also tried to add these new key/value in my info`.plist`:
```
NSUbiquitousContainers
iCloud.com.company.container-name
NSUbiquitousContainerIsDocumentScopePublic
NSUbiquitousContainerName
TEST NEW CONTAINER
NSUbiquitousContainerSupportedFolderLevels
ANY
```
### Environment, Platform, Device
• cordova -v: 11.0.0
• platform ios: 6.1.1
• cordova-plugin-file: 7.0.0
• Devices tested: iPhone7 Plus, iPhone 12 Pro, iPad Air Pro, iPad Air
Thanks for your help.
Contributor guide
Research direction
Start by reviewing the cordova-plugin-file iOS file-system layout documentation, then inspect the config.xml settings and the generated Info.plist iCloud capability entries described in the report. Reproduce writes to cordova.file.syncedDataDirectory on the listed iOS devices and verify whether the same file appears on another device; done means the behavior and required configuration are confirmed or documented.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ios, javascript
- Domain
- mobile
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100