I feel I'm missing something really obvious, but how are files copied to simulators in Device Hub now? From my MacOS Finder, there's no share with simulator option and drag and drop is ignored. What am I missing?
How to copy a file to a simulator in Device Hub?
Thanks for the post.
From Greg post at https://developer.apple.com/forums/thread/837812
xcrun simctl addmedia booted
So something like, however look at the documentation if you run it without arguments above.
xcrun simctl addmedia booted /Users/Albert/Downloads/sample.png
If the simulator is signed into an Apple ID, you can simply place the file in your Mac's iCloud Drive. Then, open the native "Files" app inside the simulator to access and download it?
Hope this helps. I highly recommend you to read Greg's post above.
Albert WWDR
Sorry, I should have been clearer. I don't want to add a media file or vCard, it's just an essentially arbitrary data file (in reality it's a backup of data - it's useful to populate the app I'm testing with data).
Syncing with iCloud isn't really an option because I think I'd have to sign both my mac and the simulator into a test apple ID? I kinda need my real Apple ID on my mac :)
Ok, I have an incredibly hacky way to do it, all from the terminal.
Use something like this to work out the ID of the simulator you want to copy a file into:
xcrun simctl list | grep Booted
Now work out the Files app group container with:
xcrun simctl get_app_container <simulator ID> com.apple.DocumentsApp groups
Make a note of the path for group.com.apple.FileProvider.LocalStorage.
Finally, use rsync to copy the file to the local storage location (cp doesn't work for some reason 🤷♂️):
rsync /path/to/my/file.dat "<LocalStorage path>/File Provider Storage/myfile.dat"
If you use cp or Finder, the copy fails and leaves a zero byte file. If you're just copying text, you can actually then open that file and just paste the text in.