Show HN: SimDrop – 在 macOS Finder 侧边栏中运行 iOS 模拟器
Show HN: SimDrop – Running iOS simulators in the macOS Finder sidebar

原始链接: https://github.com/rxliuli/sim-drop

SimDrop 是一款 macOS 应用,可在 Finder 侧栏中显示已启动的 iOS 模拟器,让你在每个模拟器的“照片”图库和“下载”文件夹之间拖拽文件。模拟器启动时出现,关闭时消失。 可通过 Homebrew 安装(`brew install --cask rxliuli/tap/sim-drop`)或从 GitHub Releases 下载 DMG;需要 macOS 15+。应用采用 Developer ID 签名并经过公证,但因需在非沙盒环境下驱动 `simctl`,未上架 App Store。 安装后,打开一次 SimDrop 以完成两项一次性授权:在“登录项”中启用后台服务,以及启用 Finder 扩展。之后它将静默运行。 拖拽默认移动文件(按住 Option 键复制)。拖放的图片/视频会通过 `simctl addmedia` 导入到模拟器的“照片”应用,其他文件则进入“下载”文件夹。“照片”为只读,导出时始终复制;删除照片会将其移至“最近删除”,删除下载文件则送入 Mac 垃圾桶(“放回”可恢复)。模拟器中的更改会在数秒内反映到 Finder。 仅支持 iOS 模拟器,不支持真机。应用由非沙盒应用、launchd 辅助程序和 File Provider 扩展组成。发布通过 GitHub Actions 自动完成,包含签名与公证。采用 GPL-3.0 许可证。

Hacker News 介绍了 Show HN:SimDrop,一个免费开源的 macOS 实用工具,用于 iOS 模拟器工作流。它在 Finder 侧边栏中放置运行中的 iOS 模拟器的 Downloads 和 Photos/Videos 文件夹,也可通过终端路径访问,并支持拖放,但有注意事项:默认移动,Option 复制,仅支持 macOS 15+ 和 iOS 模拟器。可通过 Homebrew cask 安装。评论要求截图,并包含一个无关的 Xcode JSON 问题。
相关文章

原文

Shows running iOS simulators in the Finder sidebar so you can drag files in and out of them.

SimDrop                      ← Finder sidebar › Locations
└── iPhone Duo/              ← one folder per *booted* simulator
    ├── Photos and Videos/   ← simulator Photos library
    └── Downloads/           ← Files app › On My iPhone › Downloads

Simulators appear when they boot and disappear when they shut down. Everything is also reachable from the terminal:

cp config.json ~/Library/CloudStorage/SimDrop-SimDrop/iPhone\ Duo/Downloads/
brew install --cask rxliuli/tap/sim-drop

Or download SimDrop-macos.dmg from GitHub Releases. Requires macOS 15 or later. It is Developer ID signed and notarized. SimDrop isn't on the Mac App Store and can't be: the app and its helper must run unsandboxed to drive simctl and the simulators' folders.

Open SimDrop once. The window is only a settings page showing whether these two one-time approvals are done:

  1. Background Service: allow SimDrop in System Settings › General › Login Items.
  2. Finder Extension: click Enable in the Finder banner (or turn on SimDrop under File Providers in System Settings).

After that it works silently in the background, including after a restart. The window can be closed.

After installing or upgrading, open SimDrop once. Replacing the app makes macOS drop its Finder extension (Finder then says the application can't be found) and stop the background helper. launchd refuses to start a helper whose recorded launch constraint came from the old copy (needs LWCR update, exit 78). Until the new version has been launched, no part of SimDrop can run to repair this. A Homebrew postflight_steps can't launch it either, because open fails inside the cask step sandbox. So the cask shows a caveat instead. Opening the app re-registers the extension and makes sure the helper answers with this build's version. If needed, it boots the stale launchd job out and registers the helper again.

Dragging moves by default (hold ⌥ to copy)

Finder moves files when you drag within the same volume and copies only across volumes. File Provider locations live in ~/Library/CloudStorage on your startup disk, so dragging a file from the Desktop into SimDrop moves it. iCloud Drive and Google Drive behave the same way, and File Provider has no API to change this.

  • Hold ⌥ Option while dragging to copy instead.
  • The other direction moves too: dragging a file out of a simulator's Downloads removes it from the simulator. Photos are read-only, so dragging them out always copies.

Making SimDrop copy by default like a USB drive would require it to be a separate volume (e.g. an FSKit file system), which would be a rewrite.

  • In icon view, photos show real previews without downloading them first. The extension provides downscaled thumbnails.
  • Dropped images and videos are imported with simctl addmedia, so they show up in the Photos app. iOS renames them (e.g. IMG_0007.JPG), and Finder updates the name to match.
  • Finder can't reject drops by file type, so anything that isn't an image or video is put in the same simulator's Downloads folder instead. Finder moves it there too.
  • When that happens SimDrop posts a notification saying where the file went. (Known issue: clicking the notification doesn't open Finder yet.)
  • The list mirrors the Photos library: it is read from Photos.sqlite, so photos deleted in the simulator (now in "Recently Deleted") disappear from Finder too.
  • Deleting a photo in Finder moves it to the simulator's "Recently Deleted" (recoverable there for 30 days), with no confirmation dialog. If the Photos app is open in the simulator, SimDrop relaunches it so the change shows.
  • Supports adding, opening, replacing and deleting files and folders.
  • Deleting goes to the Mac's Trash, with no confirmation dialog. The file is removed from the simulator and lands in your Trash. Put Back restores it into the simulator.
  • Renaming and moving items inside Downloads isn't supported yet, because item identifiers are path-based.
  • Changes made inside the simulator appear in Finder within a few seconds.
  • iOS simulators only. Real devices aren't supported: iOS doesn't expose the Files app storage over USB, and photos written to a real device's DCIM folder are not imported into its Photos library.
Target Sandbox Role
SimDrop (app) no Settings window. Registers the helper (SMAppService.agent) and the single File Provider domain.
SimDropHelper (launchd agent) no Starts at login. Watches ~/Library/Developer/CoreSimulator/Devices with FSEvents and tells Finder to refresh (signalEnumerator). Over XPC it runs xcrun simctl addmedia and moves deleted Downloads files to the Mac's Trash. It must be a plain tool in SimDrop.app/Contents/MacOS. As a separate .app bundle, signalEnumerator fails with "The application cannot be used right now".
SimDropFileProvider (extension) yes NSFileProviderReplicatedExtension. Reads and writes simulator folders directly through a temporary-exception entitlement, and asks the helper to import photos and to trash files.
Shared/ — Simulator discovery from device.plist (state == 3 means booted), plus path resolution.

Paths inside a simulator (~/Library/Developer/CoreSimulator/Devices/<UDID>/):

  • Downloads: data/Containers/Shared/AppGroup/<UUID>/File Provider Storage/Downloads, where the group's metadata plist has MCMMetadataIdentifier = group.com.apple.FileProvider.LocalStorage.
  • Photos: data/Media/DCIM/1xxAPPLE/. Library state comes from data/Media/PhotoData/Photos.sqlite (ZASSET, where ZTRASHEDSTATE = 0).

Implementation notes:

  • Change sync. The helper calls signalEnumerator(.workingSet). The working-set enumerator diffs against the last snapshot it handed out (stored in the extension's container) and reports removed items with didDeleteItems. Leaving an item out of the working set does not remove it from Finder.
  • Deleting photos. The helper edits Photos.sqlite directly. It updates the same ZASSET columns an in-app delete changes (ZTRASHEDSTATE, ZTRASHEDREASON, ZTRASHEDDATE, ZMODIFICATIONDATE, Z_OPT), found by diffing the table before and after deleting in the Photos app. The tables have Core Data triggers calling NSCoreDataTriggerUpdateAffectedObjectValue, which only exists inside the Photos daemon, so the helper registers a no-op function with that name. The Photos app caches the library and only shows the change after a relaunch. This is unofficial: a future iOS schema change may break it, and the helper then reports an error instead of guessing.
  • Thumbnails. Photos get previews through NSFileProviderThumbnailing. Finder only asks File Providers for thumbnails of media types, never for .app, .ipa or .zip (an app-install feature was tried and removed for now). Thumbnails are cached per content version, so bump Item.contentSchema after changing them.
  • Re-imports. After the domain reconnects (e.g. following an upgrade), the system may call createItem for folders it already had, such as a simulator folder or its Downloads / Photos and Videos. These are adopted under their real identifiers. A rejected create stays pending forever, and the system ignores deletions of a pending item, so a shut-down simulator would never disappear.
  • Folder types. Directories are always reported as public.folder, including bundles like .app. For uploads, the returned type must match the template, or the system keeps retrying the create and never uploads the children.
  • Item versions. Item.metadataSchema is part of every metadata version. Bump it when capabilities change, or Finder keeps the cached ones (e.g. photos showing as "locked").
  • Trash. The domain keeps the default supportsSyncingTrash = YES, so Finder reparents trashed items to .trashContainer. modifyItem moves the real file to the Mac's Trash through the helper, and the next sync reports the item as deleted. The extension must serve .trashContainer (an empty folder). Otherwise the domain's .Trash becomes a stale handle and Finder fails with -36.

CI (.github/workflows/release.yml) runs when MARKETING_VERSION in project.yml changes on main. It generates the project with XcodeGen, then uses rxliuli/apple-release/dmg to archive, sign with Developer ID, build the DMG, notarize, staple and publish a GitHub Release. The release-macOS environment needs these secrets: APPLE_CERTIFICATE_DEVELOPERID_BASE64, APPLE_CERTIFICATE_DEVELOPERID_PASSWORD, APPLE_API_KEY, APPLE_API_KEY_ID, APPLE_API_ISSUER, and optionally TAP_GITHUB_TOKEN. When it is set, the release also bumps Casks/sim-drop.rb in rxliuli/homebrew-tap.

No provisioning profile is involved. The app group is Team-ID-prefixed (N2X78TUUFG.com.rxliuli.sim-drop, not group.…), which macOS accepts without one.

Requires XcodeGen.

xcodegen generate
xcodebuild -project SimDrop.xcodeproj -scheme SimDrop -derivedDataPath build \
  -allowProvisioningUpdates build
# restart the extension and helper so they pick up the new build
pkill -x SimDropFileProvider; launchctl kickstart -k gui/$(id -u)/com.rxliuli.sim-drop.helper
open build/Build/Products/Debug/SimDrop.app

App icon: the source is Design/icon-source.png (a full-bleed 1024 squircle with transparent corners). Regenerate the icon set with swift Design/make-icon.swift Design/icon-source.png SimDrop/Assets.xcassets/AppIcon.appiconset. The script scales the artwork to the 824pt macOS icon grid and adds a drop shadow.

Dev launch flags:

  • open SimDrop.app --args -reregisterHelper YES re-registers the launchd agent after its plist changes.
  • open SimDrop.app --args -resetDomain YES removes the domain with all local state and re-adds it.

Don't remove the helper's launchd job on a plain uninstall (e.g. uninstall launchctl: in the cask). brew upgrade runs the old version's uninstall step before installing the new one, so the job disappears while the registration still says "enabled". The cask only does this on --zap.

Switching between a dev build and an installed release: only one copy should be registered. launchd records a launch constraint (LWCR) for the helper with the signing identity of whichever copy registered it. If that copy differs from the one now on disk (e.g. Apple Development vs Developer ID), launchd refuses to start the helper (last exit reason = OS_REASON_CODESIGNING). Quit the other copy, then run launchctl bootout gui/$(id -u)/com.rxliuli.sim-drop.helper and launch the copy you want with --args -reregisterHelper YES. Duplicate extensions (pluginkit -m -v -D -i com.rxliuli.sim-drop.FileProvider) also hide SimDrop from System Settings › Login Items & Extensions.

Logs: log stream --predicate 'subsystem == "com.rxliuli.sim-drop"'

GPL-3.0

联系我们 contact @ memedata.com