getlantern / systray

a cross platfrom Go library to place an icon and menu in the notification area
Apache License 2.0
3.28k stars 451 forks source link

Duplicate symbol error building on macOS #261

Open acastruc opened 1 year ago

acastruc commented 1 year ago

Building with wailsv2 on mac (11.6.3) I get this error

/usr/local/go/pkg/tool/darwin_amd64/link: running clang failed: exit status 1
duplicate symbol '_OBJC_CLASS_$_AppDelegate' in:
    /var/folders/hn/kchz9fwn4vxbg42s6yb3d8082p9k3x/T/go-link-109134485/000003.o
    /var/folders/hn/kchz9fwn4vxbg42s6yb3d8082p9k3x/T/go-link-109134485/000026.o
duplicate symbol '_OBJC_METACLASS_$_AppDelegate' in:
    /var/folders/hn/kchz9fwn4vxbg42s6yb3d8082p9k3x/T/go-link-109134485/000003.o
    /var/folders/hn/kchz9fwn4vxbg42s6yb3d8082p9k3x/T/go-link-109134485/000026.o
ld: 2 duplicate symbols for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Anyone seen this before? fwiw here are my build flags

INFO  Build command: go build -gcflags "all=-N -l" -tags dev,devtools -o bin/myapp-dev-darwin-amd64
OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES GO111MODULE=on TERMINAL_EMULATOR=JetBrains-JediTerm _INTELLIJ_FORCE_SET_GOROOT=/usr/local/go __CFBundleIdentifier=com.jetbrains.goland  XPC_FLAGS=0x0  GOROOT=/usr/local/go CGO_CFLAGS=-mmacosx-version-min=10.13 CGO_ENABLED=1 CGO_LDFLAGS=-framework UniformTypeIdentifiers -mmacosx-version-min=10.13 GOOS=darwin GOARCH=amd64)
anfragment commented 12 months ago

It's impossible to run systray with wails, see: https://github.com/wailsapp/wails/issues/1010#issuecomment-1038796609. The maintainers of wails are working on the new version which is planned to include tray support out of the box.

acastruc commented 9 months ago

FYI I managed to get this to work by forking branch of systray and

  1. renaming AppDelegate to SysTrayAppDelegate for all instances found in the fork project to get rid of the conflict. This lets you build. However I was using wails +macOS so I also needed to
  2. change systray_darwin.m and protect ui code with dispatch_async(dispatch_get_main_queue(), ^{ // do work here });
f1748x commented 6 months ago

Hi bro may I ask if you want to modify Wails or Systray?

FYI I managed to get this to work by forking branch of systray and

  1. renaming AppDelegate to SysTrayAppDelegate for all instances found in the fork project to get rid of the conflict. This lets you build. However I was using wails +macOS so I also needed to
  2. change systray_darwin.m and protect ui code with dispatch_async(dispatch_get_main_queue(), ^{ // do work here });

Hi bro may I ask if you want to modify Wails or Systray?