TEAM LICENSES: Save money and learn new skills through a Hacking with Swift+ team license >>

How to move .json file in apps document directory to iCloud?

Forums > SwiftUI

Hey guys,

So i have an app which saves json files to the apps directory. I'm just wondering if there was a way to save them into iCloud instead, or even have the ability to mov them into iCloud. I'm at a loss as i can't really find any information on it.

I'm wondering if the following options are okay to use? and does anyone have any examples of them?

.fileExporter
.fileMove

Thanks!

2      

Hi,

do you wan't your user to be able to access them? If so, you can use the iCloud Drive approach and copy it there. I have written a guide how to do this - https://nemecek.be/blog/6/saving-files-into-users-icloud-drive-using-filemanager This uses the FileManager and the only difference is in the URL :-)

There could be a way to save files into iCloud Drive without them being publicly exposed but I have not yet explored that.

The second option is to use CloudKit framework https://developer.apple.com/library/archive/documentation/DataManagement/Conceptual/CloudKitQuickStart/AddingAssetsandLocations/AddingAssetsandLocations.html https://developer.apple.com/documentation/cloudkit/ckasset

I have used the CKAsset to save video files and I imagine JSON is going to be very similar.

3      

Hacking with Swift is sponsored by Blaze.

SPONSORED Still waiting on your CI build? Speed it up ~3x with Blaze - change one line, pay less, keep your existing GitHub workflows. First 25 HWS readers to use code HACKING at checkout get 50% off the first year. Try it now for free!

Reserve your spot now

Sponsor Hacking with Swift and reach the world's largest Swift community!

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.