Skip to content

fix(v3): enable server mode build on macOS (darwin)#5103

Merged
leaanthony merged 8 commits intowailsapp:v3-alphafrom
RALIST:fix/server-mode-darwin-build-tags
Apr 15, 2026
Merged

fix(v3): enable server mode build on macOS (darwin)#5103
leaanthony merged 8 commits intowailsapp:v3-alphafrom
RALIST:fix/server-mode-darwin-build-tags

Conversation

@RALIST
Copy link
Copy Markdown
Contributor

@RALIST RALIST commented Mar 31, 2026

Summary

Server mode (go build -tags server) fails to compile on macOS with multiple redeclaration errors. This PR fixes the build constraints so server mode works on darwin, matching the existing Linux and Windows support.

Root cause

When AttachModal was added to the Window and webviewWindowImpl interfaces, the server mode types (BrowserWindow, serverWebviewWindow) were not updated. Additionally, most darwin-specific files (.go and .m) lack the !server build constraint — unlike their Linux and Windows counterparts which already have it. This causes darwin platform implementations and server stubs to compile simultaneously, resulting in symbol redeclaration errors.

Changes

  • 20 darwin files (14 .go + 6 .m): add && !server to build constraints
  • browser_window.go: add no-op AttachModal(Window) to satisfy Window interface
  • application_server.go: add no-op attachModal(*WebviewWindow) to satisfy webviewWindowImpl interface

Errors before this fix

clipboard_darwin.go: newClipboardImpl redeclared in this block
dialogs_darwin.go: newDialogImpl redeclared in this block
single_instance_darwin.go: newPlatformLock redeclared in this block
systemtray_darwin.go: newSystemTrayImpl redeclared in this block
webview_window_darwin.go: newWindowImpl redeclared in this block
browser_window.go: *BrowserWindow does not implement Window (missing method AttachModal)
webview_window.go: *serverWebviewWindow does not implement webviewWindowImpl (missing method attachModal)

Testing

Tested with a production Wails v3 application (30+ services, 110+ registered event types) on macOS arm64:

  • go build -tags server ./pkg/application/ — compiles clean
  • go build ./pkg/application/ — normal darwin build unaffected
  • Full application runs in server mode, serves UI at localhost:8080, IPC bindings and WebSocket events work in browser

Summary by CodeRabbit

  • New Features

    • Added modal window attachment support to improve window/modal dialog workflows.
  • Chores

    • Tightened platform build configuration so native macOS UI components are excluded from server-targeted builds, producing leaner server artifacts.

Server mode (`-tags server`) fails to compile on macOS because:

1. Most darwin-specific `.go` and `.m` files lack the `!server` build
   constraint, causing symbol redeclaration conflicts with the server
   stubs in `application_server.go`.

2. `BrowserWindow` and `serverWebviewWindow` are missing the
   `attachModal`/`AttachModal` methods added to the `Window` and
   `webviewWindowImpl` interfaces, causing interface satisfaction errors.

This was not caught because server mode was developed and tested on
Linux, where all platform files already had `!server` constraints.

Changes:
- Add `&& !server` to build constraints in 20 darwin files
  (14 .go + 6 .m)
- Add no-op `AttachModal` to `BrowserWindow` (Window interface)
- Add no-op `attachModal` to `serverWebviewWindow`
  (webviewWindowImpl interface)

Tested: full Wails application (30+ services, 110+ event types)
builds and runs successfully in server mode on macOS arm64,
serving the complete UI in a browser with working IPC.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 31, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 60c1a559-fcd8-46ac-a9e5-a01d716dd23a

📥 Commits

Reviewing files that changed from the base of the PR and between 9121fda and 9b8fd46.

📒 Files selected for processing (3)
  • v3/pkg/application/application_server.go
  • v3/pkg/application/screen_darwin.go
  • v3/pkg/application/webview_window_darwin.go
✅ Files skipped from review due to trivial changes (3)
  • v3/pkg/application/application_server.go
  • v3/pkg/application/webview_window_darwin.go
  • v3/pkg/application/screen_darwin.go

Walkthrough

Tightened build constraints on many Darwin-specific files to exclude server builds and added two server-mode no-op AttachModal methods to satisfy the modal API; no other runtime logic or exported APIs were changed.

Changes

Cohort / File(s) Summary
Darwin Build Constraint Updates (darwin && !ios → darwin && !ios && !server)
v3/pkg/application/application_darwin_delegate.m, v3/pkg/application/clipboard_darwin.go, v3/pkg/application/dialogs_darwin.go, v3/pkg/application/dialogs_darwin_delegate.m, v3/pkg/application/events_common_darwin.go, v3/pkg/application/keys_darwin.go, v3/pkg/application/mainthread_darwin.go, v3/pkg/application/menuitem_darwin.go, v3/pkg/application/menuitem_darwin.m, v3/pkg/application/screen_darwin.go, v3/pkg/application/single_instance_darwin.go, v3/pkg/application/systemtray_darwin.go, v3/pkg/application/systemtray_darwin.m, v3/pkg/application/webview_window_close_darwin.go, v3/pkg/application/webview_window_darwin.go, v3/pkg/application/webview_window_darwin.m, v3/pkg/application/webview_window_darwin_drag.m
Added !server to existing Darwin build tags so these macOS-specific implementations are excluded for server builds. No code logic changes.
Darwin Build Constraint Variants / Conditional Files
v3/pkg/application/menuitem_selectors_darwin.go, v3/pkg/application/webview_window_darwin_dev.go, v3/pkg/application/webview_window_darwin_production.go
Extended existing conditional build tags to include !server while preserving other conditions (e.g., dev/prod/devtools). No runtime logic changes.
Server Mode No-op Methods
v3/pkg/application/application_server.go, v3/pkg/application/browser_window.go
Added exported no-op server-mode methods (*serverWebviewWindow).attachModal(modalWindow *WebviewWindow) and (*BrowserWindow).AttachModal(modalWindow Window) to fulfill modal API in server builds.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested labels

Bug, MacOS, v3-alpha, go, size:M, lgtm

Poem

🐰 I scrubbed the tags, kept server away,
Modal stubs whisper, "We won't get in the way."
Darwin hops on one tidy track,
Server stays humble, GUI stays back.
🥕 Hooray for neat builds, little rabbit clap!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The PR title accurately and concisely summarizes the main change: enabling server mode builds on macOS by fixing build constraints, which aligns with the comprehensive changeset of 20 darwin files and two implementation additions.
Description check ✅ Passed The PR description is comprehensive and well-structured, covering summary, root cause analysis, detailed changes, error examples, and testing evidence. However, several optional but important template sections are not filled in: Type of change checkboxes, How Has This Been Tested section, and the Checklist items.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

leaanthony pushed a commit to RALIST/wails that referenced this pull request Apr 15, 2026
leaanthony pushed a commit to RALIST/wails that referenced this pull request Apr 15, 2026
@leaanthony leaanthony enabled auto-merge (squash) April 15, 2026 13:56
leaanthony pushed a commit that referenced this pull request Apr 15, 2026
Both scripts declare package main with func main(), causing a compile
error when Go tries to build all files in the directory together. The
build tag excludes them from normal compilation while still allowing
individual execution via `go run`.

Fixes CI error in #5103

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@leaanthony leaanthony disabled auto-merge April 15, 2026 14:34
@leaanthony leaanthony merged commit 36eea84 into wailsapp:v3-alpha Apr 15, 2026
2 of 4 checks passed
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