Skip to content

Link narrower BuddyKit products to fix duplicate Pasteboard class#699

Open
p-linnane wants to merge 1 commit into
insidegui:goldengatefrom
p-linnane:buddykit-dependency-split
Open

Link narrower BuddyKit products to fix duplicate Pasteboard class#699
p-linnane wants to merge 1 commit into
insidegui:goldengatefrom
p-linnane:buddykit-dependency-split

Conversation

@p-linnane

Copy link
Copy Markdown
Contributor

Running any VirtualBuddy binary that loads both VirtualCore and VirtualUI (including vctool and the app itself) prints duplicate-class warnings at launch:

╰─ vctool -h
objc[8870]: Class _TtC13BuddyPlatform10Pasteboard is implemented in both /Applications/VirtualBuddy.app/Contents/Frameworks/VirtualCore.framework/Versions/A/VirtualCore (0x1011c92f0) and /Applications/VirtualBuddy.app/Contents/Frameworks/VirtualUI.framework/Versions/A/VirtualUI (0x100f525c8). This may cause spurious casting failures and mysterious crashes. One of the duplicates must be removed or renamed.
objc[8870]: Class _TtC13BuddyPlatform10Pasteboard is implemented in both /Applications/VirtualBuddy.app/Contents/Frameworks/VirtualCore.framework/Versions/A/VirtualCore (0x1011c92f0) and /Applications/VirtualBuddy.app/Contents/MacOS/VirtualBuddy (0x10066fc28). This may cause spurious casting failures and mysterious crashes. One of the duplicates must be removed or renamed.
OVERVIEW: Tools for updating the VirtualBuddy software catalog.

The cause is that VirtualCore, VirtualUI, the app, and VirtualBuddyGuest all linked BuddyKit's umbrella product, which statically embeds BuddyPlatform (and BuddyKitObjC) into each binary, so the same classes get registered by more than one loaded image. This PR links only the product each target needs and drops a duplicate BuddyKit package reference.

A few call sites that used umbrella-only API were updated to match. This also drops BuddyKit's debug-only PreviewBugFix, which isn't referenced anywhere in the repo. After the change vctool -h runs clean and nm confirms BuddyPlatform.Pasteboard is present only in VirtualUI.framework.

@insidegui

Copy link
Copy Markdown
Owner

This is the thing I dislike the most about Swift Package Manager. It's supposed to catch this sort of thing and turn the products into dynamic libraries when multiple targets link against them, but apparently it doesn't work reliably 😞

This also drops BuddyKit's debug-only PreviewBugFix, which isn't referenced anywhere in the repo

PreviewBugFix is activated automatically by the runtime, it's never referenced explicitly. Have you tested SwiftUI previews to make sure that the bug it is meant to fix is no longer an issue in recent Xcode versions?

Signed-off-by: Patrick Linnane <patrick@linnane.io>
@p-linnane p-linnane force-pushed the buddykit-dependency-split branch from 71b2c69 to fdd5156 Compare June 23, 2026 15:02
@p-linnane

Copy link
Copy Markdown
Contributor Author

Good catch, you were right about PreviewBugFix being runtime-activated via +load. I must have gotten some wires crossed during testing. I'm using Xcode 27 beta.

I updated the split so VirtualUI links the BuddyKit umbrella product, while VirtualCore and the app still link only BuddyFoundation. That keeps BuddyKitObjC/PreviewBugFix loaded once without reintroducing the duplicate class warning.

I re-tested with a SwiftUI preview and saw Posting preview terminate request., so the PreviewBugFix path is still active. I also rechecked the built app: BuddyPlatform.Pasteboard and PreviewBugFix both only show up in VirtualUI.framework.

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