tauri icon indicating copy to clipboard operation
tauri copied to clipboard

[feat] Background image needed for DMG distribution file for OSX

Open alfreddagenais opened this issue 2 years ago • 4 comments

Describe the problem

I search into the documentation for the background image for a .DMG file and I not found it. I need this image when I build for MacOs.

Have a solution now or it will came soon?

Describe the solution you'd like

I just saw examples like this : 687474703a2f2f692e696d6775722e636f6d2f6c6153423432782e706e67

38463339-8e93445e-3ac6-11e8-82f8-58e6cd789077

38463360-f9bb695a-3ac6-11e8-87af-e56fbce03da9

38463361-ff0480f4-3ac6-11e8-8256-1962981b7f71

Alternatives considered

I saw the file bundle_dmg.sh from the build folder src-tauri/target/release/bundle/dmg/bundle_dmg.sh and into this file i have an option for the background

Capture-2022-07-14_01-24-03-000321

But I have no idea where I can find this file.

Capture-2022-07-14_01-25-44-000323

Additional context

No response

alfreddagenais avatar Jul 14 '22 05:07 alfreddagenais

Also looking at this part of the bundling process. The basic DMG bundling works very well but I'm at a loss at how to customise certain parts. I would at least like to use a custom background and a volume icon for the DMG itself. At the moment the first icns file found in the icons folder appears to be used (icon.icns) which is the app icon itself and unable to find a way to link a background image. The bundle_dmg.sh can't be edited as all the files appear to be regenerated on each build (both the Vol_Name and Vol_Icon in the generated .sh file just point to $2). Unable to find where the .sh script is generated from. Unable to find any sample apps with customised DMG's. Hate to think that this rudimentary customisation may involve a GitHub fork of Tauri.

Blatman avatar Aug 23 '22 16:08 Blatman

I was able to make this work for my Tauri app DMG. I had to do it manually using create-dmg.

Build your Tauri app. Get the path to the YourApp.app.

Install create-dmg:

$ brew install create-dmg

Build the DMG from the YourApp.app, pass the installer background option:

$ create-dmg
    --volname "YourAppName" \
    --volicon "path/to/your/icon.icns" \
    --background "path/to/your/background/image.png" \
    --window-pos 200 120 \
    --window-size 835 600 \
    --icon-size 128 \
    --icon "YourApp.app" 230 295 \
    --hide-extension "YouApp.app" \
    --app-drop-link 593 295 \
    "path/where/your/dmg/will/be/generated.dmg" \
     "path/to/YourApp.app"

You can find the reference on how to use create-dmg here.

An example of how I used the create-dmg for my app:

$ create-dmg \
    --volname "Zap" \
    --volicon "./src-tauri/icons/icon.icns" \
    --background "./src/assets/installer-background.png" \
    --window-pos 200 120 \
    --window-size 835 600 \
    --icon-size 128 \
    --icon "Zap.app" 230 295 \
    --hide-extension "Zap.app" \
    --app-drop-link 593 295 \
    "./src-tauri/target/aarch64-apple-darwin/release/bundle/macos/Zap.dmg" \
    "./src-tauri/target/aarch64-apple-darwin/release/bundle/macos/Zap.app"

Result: image

ahkohd avatar Sep 10 '22 22:09 ahkohd

@ahkohd thank you for the hint! I will try this tool to see it!

alfreddagenais avatar Sep 11 '22 01:09 alfreddagenais

@ahkohd thank you for the hint! I will try this tool to see it!

You're welcome. Keep in mind that you will have to tweak the icon position and design your installer background to match the configuration you provide to the create-dmg tool.

I can share my app's installer background design on Figma so that you can have a head start.

ahkohd avatar Sep 11 '22 10:09 ahkohd

fyi, if you only need to set the background, you can get away with setting some env variables because of the way the create-dmg script was written: https://github.com/create-dmg/create-dmg/blob/412e99352bacef0f05f9abe6cc4348a627b7ac56/create-dmg#L139

Setting BACKGROUND_FILE, BACKGROUND_FILE_NAME and BACKGROUND_CLAUSE in the context of the tauri build command will result in your background file being used

muryoh avatar Dec 05 '22 16:12 muryoh