Skip to content

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

Open
RALIST wants to merge 1 commit intowailsapp:v3-alphafrom
RALIST:fix/server-mode-darwin-build-tags
Open

fix(v3): enable server mode build on macOS (darwin)#5103
RALIST wants to merge 1 commit intowailsapp:v3-alphafrom
RALIST:fix/server-mode-darwin-build-tags

Conversation

@RALIST
Copy link
Copy Markdown

@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, enabling enhanced window management and modal dialog workflows across applications.
  • Chores

    • Updated build configuration constraints across platform-specific modules to properly exclude native implementations when compiling for server deployments, resulting in cleaner and more focused server builds without unnecessary platform-specific dependencies.

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: 9cdb3fea-ca51-469a-95a9-15d9e3ea4986

📥 Commits

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

📒 Files selected for processing (22)
  • v3/pkg/application/application_darwin_delegate.m
  • v3/pkg/application/application_server.go
  • v3/pkg/application/browser_window.go
  • 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/menuitem_selectors_darwin.go
  • 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_dev.go
  • v3/pkg/application/webview_window_darwin_drag.m
  • v3/pkg/application/webview_window_darwin_production.go

Walkthrough

This PR updates Go build constraints for Darwin-specific platform files to exclude server builds, and adds two no-op AttachModal method implementations for server mode compatibility.

Changes

Cohort / File(s) Summary
Darwin Build Constraint Updates (darwin && !ios → darwin && !ios && !server)
application_darwin_delegate.m, clipboard_darwin.go, dialogs_darwin.go, dialogs_darwin_delegate.m, events_common_darwin.go, keys_darwin.go, mainthread_darwin.go, menuitem_darwin.go, menuitem_darwin.m, screen_darwin.go, single_instance_darwin.go, systemtray_darwin.go, systemtray_darwin.m, webview_window_close_darwin.go, webview_window_darwin.go, webview_window_darwin.m, webview_window_darwin_drag.m
Tightened build constraints to exclude server builds across macOS-specific files; no runtime logic changed.
Complex Darwin Build Constraint Updates
menuitem_selectors_darwin.go, webview_window_darwin_dev.go, webview_window_darwin_production.go
Updated or extended existing build constraints with !server flag to exclude server builds while preserving existing condition logic.
Server Mode No-op Methods
application_server.go, browser_window.go
Added empty stub methods attachModal() and AttachModal() for server-mode compatibility with the modal window API.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~20 minutes

Possibly related PRs

Suggested labels

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

Suggested reviewers

  • leaanthony
  • atterpac

Poem

🐰 Build tags tighten, server sleeps sound,
Modal stubs dance where none are found,
Darwin stays native, server stays lean,
Platform separation, cleanly serene! 🎯

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Description check ❓ Inconclusive The PR description is comprehensive and well-structured, covering summary, root cause, changes, errors, and testing. However, it does not follow the provided template structure with required sections like 'Type of change' checklist, 'How Has This Been Tested' section, and final checklist items. Consider structuring the description to match the repository template: explicitly check the 'Type of change', provide 'How Has This Been Tested' details with test configuration, and complete the final checklist including changelog updates.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: enabling server mode build on macOS (darwin) by fixing build constraints.
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

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 OpenGrep (1.16.5)
v3/pkg/application/application_server.go

┌──────────────┐
│ Opengrep CLI │
└──────────────┘

�[32m✔�[39m �[1mOpengrep OSS�[0m
�[32m✔�[39m Basic security coverage for first-party code vulnerabilities.

�[1m Loading rules from local config...�[0m

v3/pkg/application/browser_window.go

┌──────────────┐
│ Opengrep CLI │
└──────────────┘

�[32m✔�[39m �[1mOpengrep OSS�[0m
�[32m✔�[39m Basic security coverage for first-party code vulnerabilities.

�[1m Loading rules from local config...�[0m

v3/pkg/application/clipboard_darwin.go

┌──────────────┐
│ Opengrep CLI │
└──────────────┘

�[32m✔�[39m �[1mOpengrep OSS�[0m
�[32m✔�[39m Basic security coverage for first-party code vulnerabilities.

�[1m Loading rules from local config...�[0m

  • 13 others

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.

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