wailsapp / wails

Create beautiful applications using Go
https://wails.io
MIT License
25.39k stars 1.23k forks source link

Getting rid of CGO for Linux and MacOS too (now possible) #2388

Open tapir opened 1 year ago

tapir commented 1 year ago

Is your feature request related to a problem? Please describe.

At the moment wails can dynamically load DLLs in windows but not on any other platform.

Describe the solution you'd like

https://github.com/ebitengine/purego is implemented by the developer of Ebiten (a 2D game engine for Go) and basically allows to do the same for non-windows platforms too.

Describe alternatives you've considered

I don't believe any alternatives exist at the moment.

Additional context

No response

leaanthony commented 1 year ago

I've tried this for macOS and it was really hard to get working. In fact, I was unable to get the equivalent of "get shared application and run" working. It's like it didn't want to own the run loop. Have you had more success?

I should also mention the author of ebitengine has been involved in this project and they're awesome so I think this has legs.

tapir commented 1 year ago

Unfortunately I only have access to Linux and Windows thus I can't comment on MacOS but maybe @hajimehoshi could.

hajimehoshi commented 1 year ago

You should be able to call most of Cocoa APIs. See an example https://github.com/ebitengine/purego/blob/main/examples/objc/main_darwin.go

leaanthony commented 1 year ago

I think the difference between this and what I was trying was this is using the objc runtime to build objects whereas what I was trying to do was run the main event loop via [NSApp run]. That seemed to exit immediately. I'm very excited about the possibilities here though. An ideal match for this project.

tapir commented 1 year ago

I'm glad you find it an ideal match as I believe it really compliments wails philosophy. Hoping it works!