Repository navigation
feat(macos): open files from Finder (Open With, double-click); macOS build check on PRs (#1589) - #1705
Merged
Conversation
…t launch and while running; build the macOS app on PRs that touch it (#1589)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1589.
Info.plistdeclares.sqland.sqlite/.sqlite3/.db/.db3, but on macOS "Open With" and a double-click deliver the file as an Open Documents Apple Event, not inargv, soFileLaunchService.processLaunchArgumentsnever saw it and the app opened empty.Native side (
AppDelegate.swift,MainFlutterWindow.swift)kAEOpenDocumentswhen launching starts (willFinishLaunchingNotification, the moment AppKit documents for Apple event handlers). It does not override anyFlutterAppDelegatemethod, so it does not depend on which open-file methods that class declares.querya/file_openmethod channel once its engine exists. Dart'stakePendingFilesreturns the kept ones, and from then on every new batch is sent asopenFiles.Dart side
MacOsFileOpenChannel.install()(called inmainright after the argv files) listens to the channel and takes the launch files; it is a no-op off macOS and with a runner that has no channel.FileLaunchService.parseArgument, so only.sqland SQLite files are queued, as with argv.FileLaunchService.addPendingTargetnow bumpspendingRevision;MainScreenlistens to it and opens files that arrive while the window is up (the startup path is unchanged).macOS build check (new workflow). The PR checks run on Linux, so nothing compiled Swift before a release tag.
.github/workflows/macos-build.ymlrunsflutter build macos --releaseonmacos-latestfor pull requests that touchmacos/**,pubspec.*or the workflow itself (the repository is public, so the runner is free). It runs on this PR, which is the only build check the Swift here has; whether Finder really opens a file still needs a try on a Mac.Not changed:
.db/.db3stay registered (LSHandlerRankis alreadyAlternate, so the app does not claim them by default); the issue asked to reconsider them, which is a product decision.Tests: the queue logic (openable paths queued with their kind, others and non-strings skipped, the revision bumped, non-lists ignored) and
installbeing a no-op off macOS.