Skip to content

Build the Swift binding on Linux and Windows - #33

Open
lijy91 wants to merge 3 commits into
mainfrom
swift-desktop-platforms
Open

lijy91 wants to merge 3 commits into
mainfrom
swift-desktop-platforms

Conversation

@lijy91

@lijy91 lijy91 commented Nov 12, 2026 •

Copy link
Copy Markdown
Member

The SwiftPM package currently links Cocoa and excludes every platform layer except macOS, so it cannot compile on the other two desktop targets the core supports.

This makes the package host-aware:

  • Linux compiles core/src/platform/linux and gets gtk+-3.0, x11 and xi include/link flags from systemLibrary targets using pkg-config (no unsafeFlags, so the package stays usable as a dependency).
  • Windows compiles core/src/platform/windows without the optional WinUI 3 layer and links the Win32 libraries the core imports. WindowsManifest.c embeds the Common Controls v6 manifest dependency that GetWindowSubclass needs.
  • macOS keeps the existing Cocoa/framework setup.

Two generated-code fixes make the bindings portable:

  • Swift enums convert with numericCast because an untyped C enum is UInt32 on Darwin/Linux but Int32 on Windows.
  • Generated string-list counts convert with numericCast because C long is 64-bit on Linux/macOS but 32-bit on Windows.

Verified with swift build and swift test on macOS. Linux and Windows builds, tests and a GUI smoke run are exercised by the swiftui-port CI that consumes this branch.

A C enum without a fixed underlying type is UInt32 on Darwin/Linux and Int32 on Windows. numericCast lets the generated Swift compile on all three.
C long is 64-bit on Linux/macOS and 32-bit on Windows; numericCast keeps the generated Swift compiling on all three.
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.

1 participant