Skip to content

macos/ios: use cable.connector SF Symbol for USB toolbar item#7718

Open
tan9 wants to merge 1 commit into
utmapp:mainfrom
tan9:fix/usb-toolbar-icon
Open

macos/ios: use cable.connector SF Symbol for USB toolbar item#7718
tan9 wants to merge 1 commit into
utmapp:mainfrom
tan9:fix/usb-toolbar-icon

Conversation

@tan9
Copy link
Copy Markdown

@tan9 tan9 commented May 21, 2026

Summary

The USB toolbar item was the only icon in the VM session window using a bundled bitmap (Toolbar USB.imageset) instead of an SF Symbol. Its stroke weight and overall sizing visibly differed from the surrounding system symbols (cursorarrow.rays, arrow.up.left.and.arrow.down.right, opticaldisc, folder.badge.person.crop, rectangle.on.rectangle, …). The mismatch is especially noticeable on the floating capsule toolbar introduced in macOS 26 (Tahoe), where the lighter USB stroke sticks out next to its neighbours.

usb-icon-before-after *(Before / After comparison)*

Changes

  • Platform/macOS/Display/VMDisplayWindowController.swift — override usbToolbarItem.image with NSImage(systemSymbolName: "cable.connector", …) on macOS 14+ inside a new setupToolbarIcons() helper called from windowDidLoad. Older macOS releases keep using the bundled template image from the nib.
  • Platform/iOS/VMToolbarUSBMenuView.swift — use Label("USB", systemImage: "cable.connector") on iOS 17 / macOS 14 / visionOS 1 or later. Older releases still fall back to Label("USB", image: "Toolbar USB").

The Toolbar USB.imageset bitmap is intentionally kept as a fallback for the deployment targets that don't have cable.connector (iOS 14–16, macOS 11.3–13).

Tested on

  • MacBook Pro M1 Max, macOS 26.5 (Tahoe) — built from this branch in Xcode and launched the VM session window.

Verified

  • USB toolbar item now matches the stroke weight and visual size of the adjacent SF Symbols (cursorarrow.rays, arrow.up.left.and.arrow.down.right, opticaldisc, folder.badge.person.crop, rectangle.on.rectangle) in the floating capsule toolbar on macOS 26 Tahoe — see the Before / After comparison above.

Not verified (out of scope for this change)

  • Live USB device connect / disconnect through the menu — the local development build is unsigned and lacks the Hypervisor / SPICE entitlements required to actually start a guest, so the VM session itself could not be exercised. The change only swaps the image on the existing usbToolbarItem / SwiftUI Label; no IBAction, target, menu, or enterSuspended wiring is touched, so functional behaviour should be unaffected.
  • Older macOS hosts (≤ 13) — I do not have a system on that range; the fallback path keeps the existing Toolbar USB template image from the nib, so behaviour on those releases should be identical to before.
  • iOS / iPadOS / visionOS — not built locally. The SwiftUI change is gated by #available(iOS 17, macOS 14, visionOS 1, *) and falls back to the same bundled image on older OSes.

Notes

Code is AI-assisted. The commit carries Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>.
I have read the AI Contribution Guidelines and can attest that I have followed each item to the best of my ability.

// Use the SF Symbol introduced in macOS 14 so the USB toolbar item
// visually matches the surrounding system symbols. Older systems fall
// back to the bundled "Toolbar USB" template image from the nib.
if #available(macOS 14, *) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

macOS 14? Either that means iOS wrong (iOS 17 is the aligned release) or macOS is wrong. Can you check by testing?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, thanks for catching this — both versions were wrong.

cable.connector is actually an SF Symbols 3 symbol (iOS 15 / macOS 12 / tvOS 15 / watchOS 8 / visionOS 1), not SF Symbols 5 as I had mistakenly assumed. The metadata in SFSafeSymbols (which is autogenerated from Apple's SF Symbols catalog) lists it under the @available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, visionOS 1.0, *) 3.0 extension:

@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, visionOS 1.0, *)
public extension SFSymbol {
    ...
    static var cableConnector: SFSymbol { .init(rawValue: "cable.connector") }

I've tightened the checks to:

  • Platform/macOS/Display/VMDisplayWindowController.swift: #available(macOS 12, *)
  • Platform/iOS/VMToolbarUSBMenuView.swift: #available(iOS 15, macOS 12, visionOS 1, *)

so the SF Symbol path now covers every deployment target down to the documented minimum and the bundled Toolbar USB PNG only renders on iOS 14 / macOS 11.3. Force-pushed to the same branch.

The USB toolbar item used a bundled PNG (Toolbar USB) whose stroke
weight and overall size visibly differed from the surrounding SF
Symbols (cursorarrow.rays, opticaldisc, folder.badge.person.crop,
rectangle.on.rectangle, etc.). The mismatch is especially noticeable
in the floating capsule toolbar on macOS 26 (Tahoe).

Replace the icon with the system SF Symbol cable.connector when
available (iOS 15 / macOS 12 / visionOS 1, the SF Symbols 3 release
where cable.connector was introduced), and keep the existing PNG as
a fallback for older releases.

Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
@tan9 tan9 force-pushed the fix/usb-toolbar-icon branch from b1adae0 to 1853bb9 Compare May 22, 2026 01:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants