Reputation: 31
Need easy way for users to export a data file from iOS Simulator to use on their Mac file system.
Drag and drop from Mac Finder to iOS Simulator Files app works but there isn't a files app drag and drop from iOS Simulator to Mac Finder that works.
Share sheet Copy option does put it in Clipboard but Finder app doesn't accept UTType public.data or dyn.whatever for pasting into them.
Can share base64 text with UIPasteboard.general.string fine into TextEdit or Emacs etc., but this isn't ideal as it's larger than normal and really want the binary data file format.
Can also display url of data file saved to iOS Simulator and use Mac terminal to copy from the simulator's directory space to Desktop or the like.
But a really quick, convenient, and easy way?
Upvotes: 1
Views: 35
Reputation: 31
I found a way to easily transfer data file from iOS Simulator file system to Mac Finder file system!
First, write your data file to iOS local file system:
let fileUrl = URL.documentsDirectory.appending(component: "your-file.name")
try fileData.write(to: fileUrl, options: .atomic)
Then, use the data version of your fileUrl string and feed that into the UIPasteboard.general:
let fileUrlStrData = fileUrl.absoluteString.data(using: .utf8)!
UIPasteboard.general.setData(fileUrlStrData, forPasteboardType: UTType.fileURL.identifier)
Now, open Finder app on Mac desktop and do a CMD+V paste: Your file magickally appears on Mac filesystem! w007!
Upvotes: 1