一、简介
libimobiledevice
是一个与iOS设备通信的工具集,类似于安卓上的 adb
工具,像爱思助手、PP助手等底层都是用的这个工具。
A library to communicate with services on iOS devices using native protocols.
ideviceinstaller
依赖于 libimobiledevice
,主要用于操作 App,如获取应用列表、安装卸载应用等。
A command-line application to manage apps and app archives on iOS devices.
二、安装
Mac 上可以直接利用 Homebrew 安装:
// 安装 libimobiledevice
brew install libimobiledevice
// 安装 ideviceinstaller
brew install ideviceinstaller
三、使用
下面介绍常用的命令:
1. idevice_id
打印连接的设备的 UUID
➜ ~ idevice_id -l
0e68ed5333802b17d5ac62bfa708619de597eef2
2. idevicecrashreport
把设备上的崩溃报告移到指定文件夹。
➜ ~ idevicecrashreport -u 0e68ed5333802b17d5ac62bfa708619de597eef2 crash
Move: /com.apple.appstored/appstored.log
Move: /Retired/rtcreportingd_2021-09-02-17-17-59_messageLog.ips
Move: /Retired/liveshow-2021-08-31-165309.ips
Move: /Retired/log-aggregated-2021-08-31-080228.ips
...
3. idevicedate
获取或者设置设备时间。
➜ ~ idevicedate
Thu Sep 2 17:21:12 CST 2021
4. idevicediagnostics
获取设备的诊断信息,重启设备、关闭设备等。
➜ ~ idevicediagnostics diagnostics
➜ ~ idevicediagnostics shutdown
➜ ~ idevicediagnostics restart
5. ideviceinfo
获取设备信息。
➜ ~ ideviceinfo
ActivationState: Activated
ActivationStateAcknowledged: true
BasebandActivationTicketVersion: V2
BasebandCertId: 2315222105
BasebandChipID: 241889
...
6. idevicename
获取或设置设备名称
➜ ~ idevicename iPhone🤓
device name set to 'iPhone🤓'
7. ideviceprovision
管理设备上的 provisioning profiles。
provisioning profiles 可以理解成包含了 证书、应用权限开关、appIDs、deviceIds等数据 的数据包。
➜ ~ ideviceprovision list
Device has 20 provisioning profiles installed:
50c80637-31ce-4229-805b-97f84cc0e17d - iOS Team Provisioning Profile: test.lydi.shareExtensions
...
8. idevicescreenshot
设备截图(需要设备已越狱),默认存放路径:~/screenshot-2021-09-06-03-29-15.png
➜ ~ idevicescreenshot
Screenshot saved to screenshot-2021-09-06-03-29-15.png
9. idevicesetlocation
设置设备的经纬度,可打开指南针 app 验证是否设置成功。如设置为北京的经纬度:
➜ ~ idevicesetlocation -- 39.9042 116.4074
➜ ~ idevicesetlocation reset
10. idevicesyslog
系统日志。
➜ ~ idevicesyslog -u 0e68ed5333802b17d5ac62bfa708619de597eef2
[connected]
Sep 6 11:44:02 atc(Apps)[43] <Notice>: found 42 apps using 4782030848 bytes (0 purgeable)
Sep 6 11:44:02 atc(LogsPlugin)[43] <Notice>: found 11 files [6361088 bytes] of logs in '/private/var/log/'
Sep 6 11:44:02 atc(LogsPlugin)[43] <Notice>: found 24 files [5181440 bytes] of logs in '/private/var/logs/'
Sep 6 11:44:02 atc(LogsPlugin)[43] <Notice>: found 11 files [4096 bytes] of logs in '/private/var/wireless/Library/Logs/'
...
11. ideviceinstaller
获取设备应用列表。
➜ ~ ideviceinstaller --list-apps
CFBundleIdentifier, CFBundleVersion, CFBundleDisplayName
com.buuuk.Klok, "81", "Klok"
com.tencent.xin, "7.0.4.40", "微信"
...
安装 ipa 包:
➜ ~ ideviceinstaller --install /Users/oudushu/Downloads/微信.ipa
WARNING: could not locate iTunesMetadata.plist in archive!
WARNING: could not locate Payload/liveshow.app/SC_Info/liveshow.sinf in archive!
Copying '/Users/oudushu/Downloads/微信.ipa' to device... DONE.
Installing '微信'
Install: CreatingStagingDirectory (5%)
Install: ExtractingPackage (15%)
Install: InspectingPackage (20%)
Install: TakingInstallLock (20%)
Install: PreflightingApplication (30%)
Install: InstallingEmbeddedProfile (30%)
Install: VerifyingApplication (40%)
Install: CreatingContainer (50%)
Install: InstallingApplication (60%)
Install: PostflightingApplication (70%)
Install: SandboxingApplication (80%)
Install: GeneratingApplicationMap (90%)
Install: Complete
卸载应用:
➜ ~ ideviceinstaller --uninstall 微信 (ruby-2.6.5)
Uninstalling '微信'
Uninstall: RemovingApplication (50%)
Uninstall: GeneratingApplicationMap (90%)
Uninstall: Complete