wails/v3/cmd/wails3
Lea Anthony 6d40bcd0d2 ## Summary
I have successfully implemented Mac PKG bundling for Wails v3, addressing GitHub issue #2413. Here's what was accomplished:

###  **Complete Implementation**

**1. PKG Builder (`pkg_builder.go`)**
- Uses macOS `pkgbuild` and `productbuild` tools
- Supports code signing with Developer ID certificates
- Generates distribution XML with customizable installer appearance
- Handles component and product package creation

**2. Notarization Service (`notarization.go`)**
- Full Apple notarization workflow using `notarytool`
- Automatic status polling with timeout handling
- Ticket stapling with `stapler`
- Detailed error logging and debugging support

**3. Configuration System (`config.go`)**
- YAML-based configuration with environment variable support
- Path resolution for relative paths
- Comprehensive validation
- Template generation for easy setup

**4. Command Integration (`command.go`)**
- Seamless integration with existing `wails3 tool package` command
- Support for `--format pkg` option
- Template generation with `--generate-template`
- Configuration validation with `--validate-only`

**5. CLI Integration**
- Updated `tool_package.go` to handle PKG format
- Added new flags for PKG-specific options
- Maintained backward compatibility with existing formats

###  **Key Features**

- **Professional Installers**: Creates distribution-ready PKG installers with custom branding
- **Code Signing**: Full support for Developer ID signing certificates
- **Notarization**: Automated Apple notarization with retry logic and status monitoring
- **Configuration-Driven**: YAML configuration with environment variable expansion
- **Validation**: Comprehensive dependency and configuration validation
- **Template Generation**: Automatic generation of sample configuration files
- **Cross-Platform Safe**: Only runs on macOS, provides clear error messages elsewhere

###  **Testing & Documentation**

- **Unit Tests**: Comprehensive test coverage for all components
- **Integration Tests**: CLI integration and end-to-end workflow testing
- **Documentation**: Complete README with examples, troubleshooting, and workflows
- **Error Handling**: Detailed error messages and validation feedback

###  **Usage Examples**

**Generate Template:**
```bash
wails3 tool package --format pkg --generate-template --config my-pkg.yaml
```

**Build PKG:**
```bash
wails3 tool package --format pkg --config my-pkg.yaml
```

**Validate Only:**
```bash
wails3 tool package --format pkg --config my-pkg.yaml --validate-only
```

###  **Based on Community Input**

The implementation incorporates the sample script provided by @sebheitzmann in the GitHub issue, using:
- `pkgbuild` for component package creation
- `productbuild` for final installer assembly
- Distribution XML for installer customization
- Modern `notarytool` for Apple notarization

###  **Production Ready**

The implementation is ready for v3 and includes:
- Dependency validation for required tools
- Comprehensive error handling and user feedback
- Security best practices for credential handling
- Professional installer workflows matching industry standards
- Full integration with existing Wails build system

This addresses the original GitHub issue by providing a complete Mac PKG bundling and notarization solution that integrates seamlessly with the existing Wails v3 packaging system.
2025-08-04 19:23:08 +10:00
..
main.go Add wails3 tool version command 2025-04-23 10:29:51 +10:00
README.md fix: correct Windows filename in generate:icons task 2025-04-16 15:22:05 +02:00
wails3 ## Summary 2025-08-04 19:23:08 +10:00

The Wails CLI

The Wails CLI is a command line tool that allows you to create, build and run Wails applications. There are a number of commands related to tooling, such as icon generation and asset bundling.

Commands

task

The task command is for running tasks defined in Taskfile.yml. It is a wrapper around Task.

generate

The generate command is used to generate resources and assets for your Wails project. It can be used to generate many things including:

  • application icons,
  • resource files for Windows applications
  • Info.plist files for macOS deployments

icon

The icon command generates icons for your project.

Flag Type Description Default
-example bool Generates example icon file (appicon.png)
-input string The input image file
-sizes string The sizes to generate in .ico file (comma separated) "256,128,64,48,32,16"
-windowsFilename string The output filename for the Windows icon icon.ico
-macFilename string The output filename for the Mac icon bundle icons.icns
wails3 generate icon -input myicon.png -sizes "32,64,128" -windowsFilename myicon.ico -macFilename myicon.icns       

This will generate icons for mac and windows and save them in the current directory as myicon.ico and myicons.icns.

syso

The syso command generates a Windows resource file (aka .syso).

wails3 generate syso <options>
Flag Type Description Default
-example bool Generates example manifest & info files
-manifest string The manifest file
-info string The info.json file
-icon string The icon file
-out string The output filename for the syso file wails.exe.syso
-arch string The target architecture (amd64,arm64,386) runtime.GOOS

If -example is provided, the command will generate example manifest and info files in the current directory and exit.

If -manifest is provided, the command will use the provided manifest file to generate the syso file.

If -info is provided, the command will use the provided info.json file to set the version information in the syso file.

NOTE: We use winres to generate the syso file. Please refer to the winres documentation for more information.

NOTE: Whilst the tool will work for 32-bit Windows, it is not supported. Please use 64-bit.

defaults

wails3 generate defaults      

This will generate all the default assets and resources in the current directory.

bindings

wails3 generate bindings

Generates bindings and models for your bound Go methods and structs.