背景
工具
-
libimobiledevice: linux,macOS等與ios設備通信是的工具
-
macFUSE 是 macOS 文件系統擴展的“引擎”,支持開發者創建各類虛擬文件系統。
-
iFUSE 是專為 iOS 設備設計的“連接器”,需依賴 macFUSE 實現功能。
若需訪問 iPhone/iPad 文件,必須同時安裝兩者;若僅需掛載網絡存儲或開發自定義文件系統,則只需 macFUSE。
安裝
brew install libimobiledevicebrew install --cask macfusesudo ln -s /Library/Filesystems/macfuse.fs/Contents/Resources/mount_macfuse /usr/local/bin/
sudo ln -s /Library/Filesystems/macfuse.fs/Contents/Resources/load_macfuse /usr/local/bin/
sudo ln -s /Library/Filesystems/macfuse.fs/Contents/Resources/macfuse_stat /usr/local/bin/brew install ifuse
# 或者
# 1. 添加第三方倉庫
brew tap gromgit/fuse# 2. 直接安裝適配版 ifuse
brew install gromgit/fuse/ifuse-mac # 注意使用 `-mac` 后綴# 3. 驗證版本
ifuse --version # 通常為最新穩定版(如 1.1.4+)
安裝過程遇到依賴沒有就安裝相應的依賴,網絡原因下載不了?
配置~/.bash_profile, source
brew install gromgit/fuse/ifuse-mac
lockf: 200: already locked
Error: Another `brew update` process is already running.
Please wait for it to finish or terminate it to continue.
==> Downloading https://ghcr.io/v2/gromgit/fuse/ifuse-mac/manifests/1.1.4-1
######################################################################################################################################################################################################################################################## 100.0%
==> Downloading https://formulae.brew.sh/api/formula.jws.jsonWarning: formula.jws.json: update failed, falling back to cached version.
==> Downloading https://formulae.brew.sh/api/formula.jws.json
Warning: formula.jws.json: update failed, falling back to cached version.
==> Downloading https://formulae.brew.sh/api/formula.jws.json
Warning: formula.jws.json: update failed, falling back to cached version.
==> Downloading https://formulae.brew.sh/api/formula.jws.json
Warning: formula.jws.json: update failed, falling back to cached version.
Error: Cannot download non-corrupt https://formulae.brew.sh/api/formula.jws.json!
export BASH_SILENCE_DEPRECATION_WARNING=1
export PATH=$PATH:/opt/homebrew/bin:/Users/jenkinsuser/workspace/envexport HOMEBREW_BREW_GIT_REMOTE="https://mirrors.ustc.edu.cn/brew.git"
export HOMEBREW_CORE_GIT_REMOTE="https://mirrors.ustc.edu.cn/homebrew-core.git"
export HOMEBREW_BOTTLE_DOMAIN="https://mirrors.ustc.edu.cn/homebrew-bottles"
# brew4.x API加速
export HOMEBREW_API_DOMAIN="https://mirrors.ustc.edu.cn/homebrew-bottles/api"
# hide
export HOMEBREW_NO_ENV_HINTS="1"#
export HOMEBREW_NO_INSTALL_FROM_API=1
版本不匹配?推薦版本搭配
組件 | 推薦版本 | 安裝來源 |
---|---|---|
macFUSE | 4.10.2 | brew install --cask macfuse |
ifuse | ≥1.1.4 | gromgit/fuse Tap(首選)或修改公式安裝 |
macfuse 內核拓展安裝不上?
- 重啟進入revover模式,安全選項,中開啟允許安裝第三方的內核拓展程序。
- 重啟,執行load_macfuse 加載內核拓展,在設置,安全與隱私中找到
macfuse內核拓展安裝的安裝事件。允許,即可。
使用
前置條件
- 設備要求:
- iOS 設備已通過 USB 連接到 Mac
- 設備已信任當前電腦(解鎖設備后出現的提示中選擇"信任")
- 設備已開啟文件共享(僅能訪問已啟用文件共享的應用)
- 應用要求:
- 應用必須明確啟用文件共享(在 Info.plist 中添加 UIFileSharingEnabled=true)
- 開發者應用需要有效的簽名描述文件
查找bundle id
- 使用ideviceinstaller
# 安裝工具
brew install ideviceinstaller
# 列出所有應用
ideviceinstaller -l
或者iosdeploy,cfgutil等
掛載應用的路徑
- 掛載命令
# 基本命令格式
ifuse <掛載點目錄> \--bundle-id <應用的Bundle ID> \[--documents | --container]
選項 | 作用 |
---|---|
–documents | 掛載應用的 Documents 目錄 |
–container | 掛載整個應用沙盒容器(需要開發者簽名) |
–root | 掛載整個設備文件系統(僅限越獄設備) |
# 創建掛載點
mkdir ~/myapp_documents# 掛載應用的 Documents 目錄
ifuse ~/myapp_documents --bundle-id com.mycompany.MyApp --documents# 掛載整個沙盒容器(需要開發者證書)
mkdir ~/myapp_container
ifuse ~/myapp_container --bundle-id com.mycompany.MyApp --container
訪問
應用沙盒文件夾tree如下:
├── Documents/ # 用戶文檔(通過 --documents 掛載)
├── Library/
│ ├── Preferences/ # 應用偏好設置 (.plist)
│ └── Caches/ # 緩存文件
├── tmp/ # 臨時文件
└── .com.apple.mobile_container_manager.metadata.plist # 容器元數據
卸載路徑
# 卸載指定掛載點
umount ~/myapp_documents# 強制卸載(如果普通卸載失敗)
fusermount -u ~/myapp_documents