How can my iPhone app pass CSV files to my Mac?

I recently got an Apple Watch, and now I have lots of health data on my iPhone. I'd like to get that data onto my Mac, where I can analyze it using statistical packages like "R".

As a kludge, I can run an iPhone app in the debugger to "print" the health data as CSV records to the Xcode output, and then do a "Select All", "Copy" and "Paste" to put the data into Aquamacs, where I can save to a Mac *.csv file and access it using "R"

This is straightforward, but tedious. Does anyone have another suggestion? I've considered using CloudKit or CoreData in iCloud, but both seem like overkill. Is there any way to write a CSV file to iCloud, or to connect to a file URL on my Mac over the local network from the iPhone?

Thanks.

The easiest way to do this is to have your iOS app write the file to its Documents directory and then use the Finder to download that to your Mac. You’ll need to set the UIFileSharingEnabled key in your Info.plist for it to be visible in the Finder’s device view.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Another option might also be the export function in the Health app. Tap your profile (top right)and scroll all the way down to "Export All Health Data". This will give you a ZIP archive with all data in the Health app in various formats. Most data will be in an XML document called "export.xml".

How do I find the Documents directory?

NSFileManager.url(for:in:appropriateFor:create:) passing in .documentDirectory.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

How can my iPhone app pass CSV files to my Mac?
 
 
Q