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

How to make a MacOS (Installer) DMG? #3926

Open
2 tasks done
JaneX8 opened this issue Dec 2, 2024 · 4 comments
Open
2 tasks done

How to make a MacOS (Installer) DMG? #3926

JaneX8 opened this issue Dec 2, 2024 · 4 comments
Labels
Documentation Improvements or additions to documentation

Comments

@JaneX8
Copy link

JaneX8 commented Dec 2, 2024

Have you read the Documentation Contribution Guidelines?

Description

I reluctantly purchased an M1 Apple device simply for building Wails app in the future. I have setup Homebrew, Go, Wails, Xcode and managed to build a universal .app file. Thank you for that great work. Now I only need to figure out how to test the universal app on a non-ARM Mac. And also, how to build an DMG Installer for Mac.

I've found some references to DMG files but none in the documentation and none offer a solution:

Self-service

  • I'd be willing to address this documentation request myself.
@JaneX8 JaneX8 added the Documentation Improvements or additions to documentation label Dec 2, 2024
@leaanthony
Copy link
Member

There's a node utility that does a pretty good job. There's no native go way currently (not if you want a working .DS_Store file). Mat has a good write up on the process here https://medium.com/@mattholt/packaging-a-go-application-for-macos-f7084b00f6b5

@JaneX8
Copy link
Author

JaneX8 commented Dec 2, 2024

I just figured out the basics by making this script. But I like the background in Mat's approach, I'll check that out too. Thanks.

After running wails build -platform darwin/universal -clean and setting the corrects paths I made it using:

# Set variables
APP_PATH="/Users/xx/wails-test/wails-test/build/bin/wails-test.app"
DMG_PATH="/Users/xx/wails-test/wails-test/build/bin/wails-test.dmg"
TMP_DIR="/tmp/dmg-build"
VOLUME_NAME="Wails Test"

# Clean up any existing temporary directory
rm -rf "$TMP_DIR"
mkdir -p "$TMP_DIR"

# Copy the .app file to the temporary directory
cp -R "$APP_PATH" "$TMP_DIR/"

# Create the Applications shortcut
ln -s /Applications "$TMP_DIR/Applications"

# Create the DMG file
hdiutil create -volname "$VOLUME_NAME" \
    -srcfolder "$TMP_DIR" \
    -ov \
    -format UDZO \
    "$DMG_PATH"

# Clean up temporary directory
rm -rf "$TMP_DIR"

# Output result
echo "DMG created at: $DMG_PATH"

I think it would be great to have a generic "DMG generation" option when using wails build on or for macOS to make macOS 'Installers'.

@JaneX8
Copy link
Author

JaneX8 commented Dec 2, 2024

There's a node utility that does a pretty good job. There's no native go way currently (not if you want a working .DS_Store file). Mat has a good write up on the process here https://medium.com/@mattholt/packaging-a-go-application-for-macos-f7084b00f6b5

For future reference this was mentioned in the article: https://gist.github.com/mholt/11008646c95d787c30806d3f24b2c844.

@uqix
Copy link

uqix commented Dec 25, 2024

Just found another wrapper of hdiutil: https://github.com/create-dmg/create-dmg

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

3 participants