使用libimobiledevice+ifuse访问iOS沙盒目录

libimobiledevice项目地址:https://github.com/libimobiledevice/libimobiledevice

libimobiledevice还有自己的网站:https://libimobiledevice.org/

ifuse项目地址:https://github.com/libimobiledevice/ifuse

【简介】

1、libimobiledevice是与iOS设备通信的工具。

2、ifuse是在 macOS 和 Linux 上挂载 iOS 设备文件系统的工具,依赖于 libimobiledevice 库。

【libimobiledevice安装】

之前本地已经安装了libimobiledevice,安装比较简单,这里略过。

【ifuse安装】

我使用的是mac,安装时遇到了一些小问题,

(1)我最先的安装方式是:brew install ifuse

遇到报错:Error: ifuse: Unsatisfied requirements failed this build.

testmanzhang@TestMandeMBP ~ % ifuse --version

zsh: command not found: ifuse

(2)之后安装了:brew install macfuse

(3)之后再安装:brew install ifuse --HEAD

还是报错:Error: ifuse: Unsatisfied requirements failed this build.

没办法更换安装方式,选择从源代码编译安装,适用于所有系统:

(1)git clone https://github.com/libimobiledevice/ifuse.git

遇到网络问题:

Cloning into 'ifuse'...

error: RPC failed; curl 28 Failed to connect to github.com port 443 after 75001 ms: Couldn't connect to server

fatal: expected 'packfile'

解决网络问题后继续克隆:

(2)./autogen.sh

报错:

./autogen.sh: line 10: aclocal: command not found

./autogen.sh: line 11: autoheader: command not found

./autogen.sh: line 12: automake: command not found

./autogen.sh: line 13: autoconf: command not found

./autogen.sh: line 19: ./configure: No such file or directory

这些错误是因为系统缺少 autogen.sh 需要的自动化构建工具 (autotools),包括 aclocal、automake、autoheader 和 autoconf。在 macOS 上可以通过 Homebrew 来安装这些工具。

(3)brew install autoconf automake libtool

(4)./autogen.sh

(5)make

编译的时候有一些警告信息,可以忽略:

testmanzhang@TestMandeMBP ifuse % make /Applications/Xcode.app/Contents/Developer/usr/bin/make all-recursive Making all in docs make[2]: Nothing to be done for all'. Making all in src CC ifuse.o CCLD ifuse ld: warning: ignoring duplicate libraries: '-lfuse', '-limobiledevice-1.0', '-lplist-2.0' make[2]: Nothing to be done for all-am'.

(6)sudo make install

此时安装成功:

testmanzhang@TestMandeMBP ifuse % ifuse --version

ifuse 1.1.5

【挂载】

(1)为挂载 iOS 应用的沙盒目录创建一个本地目录:

mkdir -p ~/ios_sandbox/iPhone\ X

但是挂载的时候提示:

testmanzhang@TestMandeMBP ~ % ifuse ~/ios_sandbox/iPhone\ X --udid f89d91234567a81c0fe2d22f80c1a123456790ef --appid com.1234567.ios

ERROR: the mount point specified does not exist

但目录确实是存在的:

testmanzhang@TestMandeMBP ~ % ls -ld ~/ios_sandbox/iPhone\ X

drwxr-xr-x 2 testmanzhang staff 64 10 28 10:49 /Users/testmanzhang/ios_sandbox/iPhone X

修改权限后依然不行:

testmanzhang@TestMandeMBP ~ % chmod 777 ~/ios_sandbox/iPhone\ X

testmanzhang@TestMandeMBP ~ % ifuse ~/ios_sandbox/iPhone\ X --udid f89d91234567a81c0fe2d22f80c1a123456790ef --appid com.1234567.ios

ERROR: the mount point specified does not exist

删除目录后重新创建:testmanzhang@TestMandeMBP ~ % mkdir -p ~/ios_sandbox/iPhoneX

还是提示:ERROR: the mount point specified does not exist

使用sudo也是不行,

后来改成完整路径,也是不行:

testmanzhang@TestMandeMBP ios_sandbox % ifuse /Users/testmanzhang/ios_sandbox --udid f89d91234567a81c0fe2d22f80c1a123456790ef --appid com.1234567.ios

ERROR: the mount point specified does not exist

后来看了一下:

testmanzhang@TestMandeMBP ~ % ifuse -h

修改了一下命令的写法:

testmanzhang@TestMandeMBP ~ % ifuse --container com.glazero.ios -o ~/ios_sandbox

ERROR: No mount point specified

testmanzhang@TestMandeMBP ~ % ifuse ~/ios_sandbox --container com.glazero.ios

mount_macfuse: the file system is not available (1)

看到这个提示,感觉差不多了,这是电脑上弹出提示:

重启电脑

在手机上也会弹出提示,点击 允许:

重启电脑后,需要拔插一下数据线(此时libimobiledevice也会提示:No device found!):

testmanzhang@TestMandeMBP ~ % ideviceinfo

ERROR: No device found!

但是idevice_id -l 不会有任何提示

当时怀疑安装了ifuse后会把libimobiledevice卸载掉,确认了一下,不会卸载:

testmanzhang@TestMandeMBP ~ % brew list | grep libimobiledevice

libimobiledevice

libimobiledevice-glue

插拔一下数据线就好了。

再次执行挂载成功:

【意外的错误】

电脑休眠后再次打开时,再次挂载会提示这个错误:

testmanzhang@TestMandeMBP ~ % ifuse ~/ios_sandbox/iPhoneX --container com.glazero.ios

There was an error accessing the mount point: Input/output error

此时挂载了iphoneX的上级目录,挂载成功:

testmanzhang@TestMandeMBP ~ % ifuse ~/ios_sandbox --container com.1234567.ios

testmanzhang@TestMandeMBP ~ %

testmanzhang@TestMandeMBP ~ % ls ios_sandbox

Documents Library SystemData tmp

如果是重复挂载的话应该提示这个错误:

testmanzhang@TestMandeMBP ~ % ifuse ~/ios_sandbox/iPhoneX --container com.1234567.ios --udid f89d91234567a81c0fe2d22f80c1a123456790ef

mount_macfuse: mount point /Users/testmanzhang/ios_sandbox/iPhoneX is itself on a macFUSE volume

【卸载】

testmanzhang@TestMandeMBP ~ % fusermount -u ~/ios_sandbox

zsh: command not found: fusermount

ifuse没有这个命令fusermount。

卸载命令是umount:

testmanzhang@TestMandeMBP ~ % umount ~/ios_sandbox

testmanzhang@TestMandeMBP ~ % ls ios_sandbox

iPhoneX

testmanzhang@TestMandeMBP ~ % cd ios_sandbox/iPhoneX

cd: Input/output error: ios_sandbox/iPhoneX

但是ios_sandbox/iPhoneX还是有问题,这个目录不能删除:

testmanzhang@TestMandeMBP ios_sandbox % rm -rf ~/ios_sandbox/iPhoneX

testmanzhang@TestMandeMBP ios_sandbox % mkdir ~/ios_sandbox/iPhoneX

mkdir: /Users/testmanzhang/ios_sandbox/iPhoneX: File exists

上级目录也是没有权限删除:

testmanzhang@TestMandeMBP ios_sandbox % rm -rf ~/ios_sandbox

rm: /Users/testmanzhang/ios_sandbox: Permission denied

使用sudo后也是不可以:

testmanzhang@TestMandeMBP ~ % sudo rm -rf ~/ios_sandbox

rm: /Users/testmanzhang/ios_sandbox/iPhoneX: Input/output error

rm: /Users/testmanzhang/ios_sandbox: Permission denied

后来查了一下这个目录是否正在挂载,结果确实在挂载中:

testmanzhang@TestMandeMBP ~ % mount | grep ios_sandbox

ifuse@macfuse0 on /Users/testmanzhang/ios_sandbox/iPhoneX (macfuse, nodev, nosuid, synchronous, mounted by testmanzhang)

卸载这个目录,再查没有挂载关系:

testmanzhang@TestMandeMBP ~ % umount /Users/testmanzhang/ios_sandbox/iPhoneX

testmanzhang@TestMandeMBP ~ % mount | grep ios_sandbox

再次执行挂载:

testmanzhang@TestMandeMBP ~ % ifuse ~/ios_sandbox/iPhoneX --container com.1234567.ios --udid f89d91234567a81c0fe2d22f80c1a123456790ef

testmanzhang@TestMandeMBP ~ %

挂载关系生成:

testmanzhang@TestMandeMBP ~ % mount | grep ios_sandbox/iPhoneX

ifuse@macfuse0 on /Users/testmanzhang/ios_sandbox/iPhoneX (macfuse, nodev, nosuid, synchronous, mounted by testmanzhang)

testmanzhang@TestMandeMBP ~ % ls ios_sandbox/iPhoneX

Documents Library SystemData tmp

这样的话在本地就可以访问沙盒目录了:

相关推荐
程序猿看视界2 小时前
如何在 UniApp 中实现 iOS 版本更新检测
ios·uniapp·版本更新
dr李四维6 小时前
iOS构建版本以及Hbuilder打iOS的ipa包全流程
前端·笔记·ios·产品运营·产品经理·xcode
️ 邪神6 小时前
【Android、IOS、Flutter、鸿蒙、ReactNative 】自定义View
flutter·ios·鸿蒙·reactnative·anroid
比格丽巴格丽抱17 小时前
flutter项目苹果编译运行打包上线
flutter·ios
网络安全-老纪19 小时前
iOS应用网络安全之HTTPS
web安全·ios·https
1024小神21 小时前
tauri2.0版本开发苹果ios和安卓android应用,环境搭建和最后编译为apk
android·ios·tauri
lzhdim1 天前
iPhone 17 Air看点汇总:薄至6mm 刷新苹果轻薄纪录
ios·iphone
安和昂1 天前
【iOS】知乎日报第四周总结
ios
麦田里的守望者江1 天前
KMP 中的 expect 和 actual 声明
android·ios·kotlin
_黎明1 天前
【Swift】字符串和字符
开发语言·ios·swift