You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To access to your iCloud Drive folder, we use FileManager to retrieve the folder.
Returns the URL for the iCloud container associated with the specified identifier and establishes access to that container.
If you specify nil for this parameter, this method returns the first container listed in the com.apple.developer.ubiquity-container-identifiers entitlement array.
Note that the ubiquity folder retrievement can take some time
Do not call this method from your app’s main thread. Because this method might take a nontrivial amount of time to set up iCloud and return the requested URL, you should always call it from a secondary thread. To determine if iCloud is available, especially at launch time, check the value of the ubiquityIdentityToken property instead
Here I use EasyStash for easy read and write operations
import Foundation
import EasyStash
actorCloudDriveService{staticletshared=CloudDriveService()private(set)varstorage:Storage?init(){
guard
let containerUrl =FileManager.default
.url(forUbiquityContainerIdentifier:nil)else{return}letfolderUrl= containerUrl.appendingPathComponent("Documents")varoptions=Options()
options.directoryUrl = folderUrl
storage =try?Storage(options: options)}}
Remember to appendingPathComponent with a folder name to your iCloud Drive root folder
In case you don't see your app folder in iCloud Drive folder, bump CFBundleVersion
If you still don't use your app in iCloud Drive folder despite all read-write operation works, you can try browsing your ubiquity folder folderUrl using Terminal with ls
The text was updated successfully, but these errors were encountered:
First, you need to enable
iCloud Documents
capability. Go to target settings -> Signing & Capabilities -> iCloud`
Then inside your
Info.plist
, add this with your iCloud identifier and app nameTo access to your iCloud Drive folder, we use FileManager to retrieve the folder.
Note that the ubiquity folder retrievement can take some time
Here I use EasyStash for easy read and write operations
When I print the
folderUrl
on macOS, I geton iOS, it will be like this
Troubleshoot
appendingPathComponent
with a folder name to your iCloud Drive root folderCFBundleVersion
folderUrl
using Terminal withls
The text was updated successfully, but these errors were encountered: