Fix #295: open files from the macOS Finder and Dock

Finder, Open With, a drop on the Dock icon and `open -a` failed with "VectorCraft cannot open
files in the PDF document format":

- The release Info.plist declared no document types, so Launch Services refused the files before
  the app saw them. Info.plist.in now declares every format File › Open reads (the engine's
  OPEN_EXTS; a test keeps them in step): VectorCraft owns its own documents and templates and is an
  alternate for the others, so it takes over no other app's files. `cargo xtask bundle` now fills
  in the same template instead of its own, shorter plist.
- macOS delivers such files as open-document events, not arguments. winit 0.30's application
  delegate has no `application:openURLs:`, so AppKit fell back to NSDocumentController, which
  refuses every file of a non-NSDocument app (the error in both issues). The new
  `open_documents` module adds that method to the delegate's class when the app is about to finish
  launching (before AppKit delivers launch files), queues the paths and wakes the UI, which opens
  them with `io::open_path` like command-line files; errors go to the status bar too.

New direct macOS dependencies `objc2-foundation` 0.3 and `block2` 0.6 were already in Cargo.lock
(through winit, muda and rfd). The module allows `unsafe_code` for the Objective-C runtime call.

Fixes #354

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
bflatastic
2026-10-08 05:28:50 +07:00
co-authored by Claude Opus 5.5
parent accfec7146
commit b2c6764472
8 changed files with 254 additions and 39 deletions
+7 -1
View File
@@ -67,7 +67,13 @@ The rules are in craftrules `standards/fonts.md`, the build option in
- `Info.plist` is generated from `Info.plist.in` (bundle id `ai.storyteller.vectorcraft`,
`LSMinimumSystemVersion` 11.0, the version and the build commit). The icon is
`assets/app-icon/vectorcraft.icns`.
`assets/app-icon/vectorcraft.icns`. `cargo xtask bundle` fills in the same template for its
development app.
- **Document types:** `Info.plist.in` declares every format File › Open reads, so Finder opens
them with VectorCraft (double-click, Open With, a drop on the Dock icon). VectorCraft owns its own
formats and is an alternate for the others. A test keeps the list in step with the engine's
`OPEN_EXTS`. AppKit hands the files to the app as open-document events, which
`apps/vectorcraft/src/open_documents.rs` opens like files named on the command line.
- **Signing** goes inside-out with the hardened runtime and a secure timestamp: the executable
first, then the bundle, with no `--deep` on the final signature. The entitlements
(`entitlements.plist`) are deliberately empty.