Repository navigation
macOS: the app's icon in the Dock and the app switcher for a build outside a bundle - #3
Merged
Merged
Conversation
…tside a bundle AppKit takes an app's icon from its bundle, which only the packaged app has, so a development build (cargo run, target/release/dv) showed the generic executable icon in the Dock and the app switcher. At startup such a build now hands AppKit the bundle's own resources/macos/dv.icns (-[NSApplication setApplicationIconImage:], dock_icon.rs); a bundled app keeps its own. objc2 joins dv's macOS dependencies, with gui only. PLAN §13.1.
Owner
|
thanks for all three of these :) |
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.
Summary
On macOS, AppKit takes an app's Dock and app-switcher icon from its bundle's
CFBundleIconFile. Only the packaged app (script/package) has a bundle, so a development build (cargo run -p dv,target/release/dv,script/check-macruns) shows the generic executable icon in the Dock and⌘Tab.At startup, a build that isn't running from an
.appnow hands AppKit the bundle's own icon:crates/dv/resources/macos/dv.icns, embedded withinclude_bytes!and set through-[NSApplication setApplicationIconImage:]. A bundled app keeps its own and is left alone.How
crates/dv/src/dock_icon.rs(macOS,guionly): checks-[NSBundle mainBundle] bundlePathfor.app, else builds anNSImagefrom the icon's bytes and sets it. Every returned object is checked for nil, and it does nothing if AppKit can't read the image. Rawmsg_send!, asgpui_automationdoes, so no AppKit bindings crate.app.rscalls it after startup, before activation.objc2(the workspace's 0.6) joinsdv's macOS dependencies, optional withgui, so the headless build doesn't get it.cargo tree -p dv --no-default-featureslists the sameobjc2-*crates as before, fromnotify's file watcher.Testing
is_app_bundleon bundle and plain paths, and that the embedded bytes are anicnsfile.cargo test -p dv -p dv_uipasses. Checked by hand that a release build outside a bundle shows the dv mark in the Dock and⌘Tab. The e2e runner's background mode makes the app an accessory (no Dock icon), so no scenario can show it..pkg(needs .NET);dock_iconreturns early there because its main bundle is the.app.Independent of #1 and #2.