Open Mariownyou opened 11 months ago
Hi @Mariownyou, Go doesn't build an .app
file but you can create it yourself.
You can try building the program statically so all dependencies is contained using:
CGO_ENABLED=1 GOOS=darwin GOARCH=arm64 go build -tags static -ldflags "-s -w" -o app
After that you can create the following directory structore for the app bundle. Here the name is GoSDL2.app
as example.
GoSDL2.app
└── Contents
├── Info.plist
├── MacOS
│ └── app
└── Resources
├── app.icns
└── example.bmp
The content of Info.plist
is the following:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleExecutable</key>
<string>app</string>
<key>CFBundleIconFile</key>
<string>app</string>
</dict>
</plist>
Then you can copy the executable app
to GoSDL2.app/Content/MacOS/
and if you have any resource like image files, you can put them under GoSDL2.app/Content/Resources/
.
As for hiding terminal when building, could you elaborate more on that? Is that a problem somehow?
Thank you for providing information regarding creating .app bundle.
About terminal issue, I would like to hide terminal when builing app
HI @Mariownyou, do you mean that you want to hide terminal when running the app instead of building the app? I think you could create the app bundle like above and run it. In that case it won't show the Terminal
Thanks, I will try this :)
Go version: latest Go-SDL2 version: SDL2 version: OS: macOS Architecture: Apple Silicon