问题
I am looking for a way to transfer files from my Mac to the iPhone via USB, and it needs to be done either using the terminal or programmatically.
So far, I have seen some other questions on that topic on StackOverflow, and the most common reply was to use GUI-tools such as iExplorer. Unfortunately, I cannot use GUI-based tools.
One interesting answer was this one (https://stackoverflow.com/a/15795578/299711), which mentioned the MobileDevice library, but alas, it seems very poorly documented (rather, not documented at all, which is not surprising given the fact that it's a private API).
Another answer I found mentioned fruitstrap (https://stackoverflow.com/a/11061932/299711), however, a) I need to be able to copy files in both directions, and b) I need to copy files that are not contained within an application, but which can be located anywhere on the iOS device.
I would be willing to develop a command-line tool myself, if I were to find any documentation is to how to use the MobileDevice framework. But if there already is such a command-line tool which supports bidirectional file transfers, please point me to it. Also, I do not mind having to jailbreak the device if necessary. Thanks!
回答1:
There is a way to do this, but you have to jailbreak the device and then install from Cydia AFC2 tweak (if not provided with the jailbreak; the latest version of Pangu includes AFC2).
http://www.iphonehacks.com/2014/06/saurik-afc2-package-ios-7-1-x-full-filesystem-access-usb.html
This way you are no longer limited to the Media folder on the device. For how to implement the comunication, i recomend having a look on a project from Github
https://github.com/Moligaloo/iPhoneFS
The Mobile Device library on PC comes with iTunes, so you have to install iTunes, locate the library and link agains it. Hope this helps
回答2:
Possible With Jailbroken Device:
- install OpenSSH on device-using cydia app
now to tranfer file from MAC to iOS use following command on your's mac terminal
scp filePathForYourFileInMac root@ipaddressOfIPhone:destinationPathInIphone
This will transfer file from your mac to iphone at destination place.
If above command asks for Password, use "alpine"(it is default password for root user on jailbroken device). If you have already changed your root passwd, then use that passwd.
来源:https://stackoverflow.com/questions/25888498/transfer-files-from-computer-mac-to-ios-device-jailbroken-if-necessary-via-u