Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible to compile to .app on macOS? Also, is there a way to hide terminal when building #574

Open
Mariownyou opened this issue Jul 28, 2023 · 4 comments

Comments

@Mariownyou
Copy link

Go version: latest
Go-SDL2 version:
SDL2 version:
OS: macOS
Architecture: Apple Silicon

@veeableful
Copy link
Contributor

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?

@Mariownyou
Copy link
Author

Thank you for providing information regarding creating .app bundle.

About terminal issue, I would like to hide terminal when builing app
image

@veeableful
Copy link
Contributor

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

@Mariownyou
Copy link
Author

Thanks, I will try this :)

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

No branches or pull requests

2 participants