Programmatically get iOS device screenshot from the connected Mac computer

£可爱£侵袭症+ 提交于 2019-11-30 08:18:46

问题


I know it's possible to get a screenshot programmatically from code in the iOS application, and to manually get screenshots from Xcode and Instruments (Instruments also automatically takes screenshots during UIAutomation test failures). What I would like to find is a programatic way (with code running on the Mac, not the device) to grab screenshots from the device onto the Mac which it is plugged into.

Is there an API (or command-line parameters) into Xcode or Instruments to get access to this screenshot feature? Or (ideally) to interface to the device and get a screenshot directly, the same way that Xcode and Instruments do it?


回答1:


Yes, there is a way. You want to install the free libimobiledevice library: https://github.com/benvium/libimobiledevice-macosx

When it is installed, you can run idevicescreenshot from the commandline and it will save a TIFF file with a screenshot to the current directory.

See http://pervasivecode.blogspot.de/2012/06/take-iphone-or-ipad-screenshot-from.html




回答2:


I do not know how to programmatically get the screenshot off of the device and onto your Mac, but you can go into Organizer while you are running your application, select the device in the list, and under the Screenshots sub-menu, click on the New Screenshot button. You do not even have to be debugging the application, this can be done at any time.

One of the more useful applications of this feature is being able to capture a default screen for the launch image, or creating the images needed for the App Store sample images.




回答3:


Check to see if there is a Applescript dictionary entry for Xcode for Organizer snapshot. If so, programmatically call or run this Applescript function.



来源:https://stackoverflow.com/questions/7311332/programmatically-get-ios-device-screenshot-from-the-connected-mac-computer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!