mac 系統實在是有點貴,網上找了找看能不能通過添加系統庫來實作在 windows/ubuntu 上實作來擷取 iphone 等 ios 系統相關的資訊,進而發現了 libimobiledevice
庫, 可以通過使用其中的協定接口來對裝置進行資料讀寫操作。具體安裝方式如下:
<b> 注意: 如下操作都在 cygwin 中進行的</b>
- plist 庫安裝
sudo apt-get install libxml2-dev python-dev python-pip
sudo pip install cython
git clone https://github.com/libimobiledevice/libplist.git
cd libplist
./autogen.sh
make
sudo make install
- libusbmuxd 庫安裝
git clone https://github.com/libimobiledevice/libusbmuxd.git
cd libusbmuxd
./autogen.sh
make
sudo make install
<b>[問題]</b> 可能會出現如下錯誤之後:
checking for libplist... no
configure: error: Package requirements (libplist >= 1.11) were not met:
No package 'libplist' found
Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.
Alternatively, you may set the environment variables libplist_CFLAGS
and libplist_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.
可以通過如下方式解決
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig
注意上述路徑是指在 libplist 庫中 src/*.pc 檔案安裝的目錄
- libimobiledevice 庫安裝
git clone https://github.com/libimobiledevice/libimobiledevice.git
cd libimobiledevice
./autogen.sh
make
sudo make install
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
這時候我們能執行 idevice_id,ideviceinfo,idevicename 等指令。
- usbmuxd 庫安裝
git clone https://github.com/libimobiledevice/usbmuxd.git
cd usbmuxd
./autogen.sh
make
sudo make install
該庫必須安裝,否則沒法使用上述指令,該庫的作用就是提供 usb 通訊通道, 該部分依賴 usb 開發包 libusb-dev 是以,需要用 cygwin 安裝包進行安裝
- ideviceinstaller 安裝
git clone https://github.com/libimobiledevice/ideviceinstaller.git
cd ideviceinstaller
./autogen.sh
make
sudo make install
主要用來 ipa 包安裝等相關工具。
<b>[問題]</b> 出現如下錯誤:
$ make
make all-recursive
make[1]: Entering directory '/cygdrive/d/workspace/libimobiledevice/ideviceinstaller'
Making all in src
make[2]: Entering directory '/cygdrive/d/workspace/libimobiledevice/ideviceinstaller/src'
CC ideviceinstaller-ideviceinstaller.o
ideviceinstaller.c: In function ‘main’:
ideviceinstaller.c:864:9: error: implicit declaration of function ‘asprintf’ [-Werror=implicit-function-declaration]
if ((asprintf(&pkgname, "%s/%s", PKG_PATH, basename(ipcc)) > 0) && pkgname) {
^
cc1: all warnings being treated as errors
make[2]: *** [Makefile:430: ideviceinstaller-ideviceinstaller.o] Error 1
make[2]: Leaving directory '/cygdrive/d/workspace/libimobiledevice/ideviceinstaller/src'
make[1]: *** [Makefile:395: all-recursive] Error 1
make[1]: Leaving directory '/cygdrive/d/workspace/libimobiledevice/ideviceinstaller'
make: *** [Makefile:326: all] Error 2
解決辦法如下:
刪除 src/Makefile 檔案内的 GLOBAL_CFLAGS 中的 -Werror