Skip to content

Conversation

@ColeMurray
Copy link

@ColeMurray ColeMurray commented Jan 21, 2026

Summary

Fixes #53 - CloudStorageScope.Documents was writing to local storage instead of iCloud Documents.

The documentsDirectory property in CloudKitUtils.swift was using the local sandbox Documents folder:

fileManager.urls(for: .documentDirectory, in: .userDomainMask).first

This has been changed to use the iCloud ubiquity container's Documents folder:

fileManager.url(forUbiquityContainerIdentifier: nil)?.appendingPathComponent("Documents")

Why This Fix Is Correct

According to Apple's FileManager documentation:

Returns the URL for the iCloud container associated with the specified identifier and establishes access to that container.

The iCloud ubiquity container has a specific structure where only files in the Documents subfolder are visible to users in the Files app. From Apple's iCloud Design Guide:

Place documents that the user creates and manages in the Documents subdirectory of the iCloud container.

The original implementation used fileManager.urls(for: .documentDirectory, in: .userDomainMask).first which returns the local app sandbox Documents folder (e.g., /var/mobile/Containers/Data/Application/{UUID}/Documents/), not the iCloud container at all.

Behavior Change

Scope Before After
Documents Local sandbox (not synced) iCloud Documents (synced, visible in Files app)
AppData iCloud container root (synced, hidden) No change

This aligns with the library's documented behavior which states Documents scope should store data in "the user-visible root directory of the cloud storage".

Test Plan

  1. Use CloudStorageScope.Documents to write a file
  2. Verify the file appears in Files app under iCloud Drive → [App Name]
  3. Verify the file syncs to other devices signed into the same iCloud account
  4. Verify CloudStorageScope.AppData still works as expected (synced but hidden)

The documentsDirectory property was incorrectly using the local
sandbox Documents folder instead of the iCloud ubiquity container's
Documents folder.

This meant files written with CloudStorageScope.Documents were stored
locally and not synced to iCloud, contrary to the documented behavior.

Fixes kuatsu#53
@netlify
Copy link

netlify bot commented Jan 21, 2026

Deploy Preview for react-native-cloud-storage ready!

Name Link
🔨 Latest commit 855a839
🔍 Latest deploy log https://app.netlify.com/projects/react-native-cloud-storage/deploys/697049bc8ee9c80008969471
😎 Deploy Preview https://deploy-preview-54--react-native-cloud-storage.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

iOS: CloudStorageScope.Documents writes to local storage instead of iCloud Documents

1 participant