fyne-io / fyne

Cross platform GUI toolkit in Go inspired by Material Design
https://fyne.io/
Other
25.06k stars 1.39k forks source link

Can not retrieve metadata in application, specified by package parameters when using package on precompiled binary #5230

Open chran554 opened 1 week ago

chran554 commented 1 week ago

Checklist

Describe the bug

When packageing my application with "fyne package" on a compiled fyne binary, I can not retrieve the metadata from within the application.

How to reproduce

  1. Build application with "go build". go build -o metadataapp fynemetadata/main.go
  2. Package application with "fyne package" and metadata parameters. fyne package --executable metadataapp --name "Metadata App" --appID="com.dummy.id" --appVersion="1.2.3" --appBuild=42 --icon star-icon.png
  3. Run application with no success to find specified metadata during package. open Metadata\ App.app

Screenshots

image

Example code

<project root>
├── fynemetadata
│   └── main.go
├── go.mod
├── go.sum
└── star-icon.png

File: fynemetadata/main.go

package main

import (
    "fmt"

    "fyne.io/fyne/v2/app"
    "fyne.io/fyne/v2/container"
    "fyne.io/fyne/v2/widget"
)

func main() {
    application := app.New()
    window := application.NewWindow("Fyne metadata test")
    metadataLabel := widget.NewLabel(fmt.Sprintf("%+v\n", application.Metadata()))
    window.SetContent(container.NewBorder(metadataLabel, nil, nil, nil))
    window.ShowAndRun()
}

Fyne version

fyne cli version: v2.5.2

Go compiler version

go version go1.23.2 darwin/arm64

Operating system and version

Apple M1 Apple silicon, macOS Sonoma 14.6.1 (23G93)

Additional Information

Workaround: In the case you have access to the code you can specify the source directory at package time. Qualified guess is that the program will be recompiled (not using the already compiled binary) with extra generated application init file (setting up the metadata).

fyne package --src fynemetadata/ --executable metadataapp --name "Metadata App" --appID="com.dummy.id" --appVersion="1.2.3" --appBuild=42 --icon ../star-icon.png

But that still makes this issue with "fyne package" using precompiled binary valid, since it will miss the metadata in the application.

andydotxyz commented 1 week ago

The metadata is injected into the application, to do that it needs to compile it with the appropriate options.

It is not clear why you are pre-compiling separate to the fyne package command, but if that is part of your worflow consider "fyne build" instead of "go build" as that will insert your metadata.

chran554 commented 5 days ago

ok, maybe it is a matter of documentation to clearify that the parameters are of no use when using executable?

Even better, let the "package" command make the options "executable" and "sourceDir" mutually exclusive with printed error message if you try to specify both? Also print warning or error if you try to use app and metadata parameters when specifying "executable", since they can not be used/are ignored/is of no use?

andydotxyz commented 5 days ago

We could perhaps take that approach, but it is not quite that simple. The parameters will have effect in many areas - it's just that "App.Metadata()" call which requires "fyne package" or "fyne build" to have been used in binary creation.

The metadata for the OS (except on Windows) is in the packaging format and will have effect irrespective of whether you built it outside the ecosystem.

It would probably be a simpler documentation change to just specify that "fyne package" or "fyne build" must be used to correctly package a fyne app.