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

bugfix : fix error on building runnable .app on MacOS when 'name' and 'outputfilename' are different. #3789

Conversation

nickisworking
Copy link
Contributor

@nickisworking nickisworking commented Sep 28, 2024

mod : added OutputFilename field to assetData
mod : modified resolveProjectData to export OutputFilename
mod : modified CFBundleExecutable values to .OutputFilename in info.dev.plist, info.plist

Description

There was an issue where the executable file was not properly generated when the name and outputfilename in the existing wails.json were different. The cause of this issue was that outputfilename was not being used under pkg/buildassets. As a result, I have modified the code to properly export outputfilename and use it in CFBundleExecutable as well.

Fixes #3786

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

After building Wails with the modified source code, go build ./cmd/wails
I built a test project using the generated binary.

  • Windows
  • macOS
  • Linux

Test Configuration

# Wails
Version | v2.9.2

# System
┌────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
| OS           | MacOS                                                                                                                       |
| Version      | 14.4.1                                                                                                                      |
| ID           | 23E224                                                                                                                      |
| Go Version   | go1.23.0                                                                                                                    |
| Platform     | darwin                                                                                                                      |
| Architecture | arm64                                                                                                                       |
| CPU          | Apple M1 Max                                                                                                                |
| GPU          | Chipset Model: Apple M1 Max Type: GPU Bus: Built-In Total Number of Cores: 24 Vendor: Apple (0x106b) Metal Support: Metal 3 |
| Memory       | 32GB                                                                                                                        |
└────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘

# Dependencies
┌─────────────────────────────────────────────────────────────────────────┐
| Dependency                | Package Name | Status    | Version          |
| Xcode command line tools  | N/A          | Installed | 2406             |
| Nodejs                    | N/A          | Installed | 16.20.2          |
| npm                       | N/A          | Installed | 8.19.4           |
| *Xcode                    | N/A          | Installed | 14.3.1 (14E300c) |
| *upx                      | N/A          | Available |                  |
| *nsis                     | N/A          | Available |                  |
└──────────────────────── * - Optional Dependency ────────────────────────┘

# Diagnosis
Optional package(s) installation details: 
  - upx : Available at https://upx.github.io/
  - nsis : More info at https://wails.io/docs/guides/windows-installer/

 SUCCESS  Your system is ready for Wails development!

 ♥   If Wails is useful to you or your company, please consider sponsoring the project:
https://github.com/sponsors/leaanthony

Checklist:

  • I have updated website/src/pages/changelog.mdx with details of this PR
  • My code follows the general coding style of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Summary by CodeRabbit

  • New Features
    • Introduced a new OutputFilename field to enhance asset data structure.
  • Bug Fixes
    • Resolved a build error on macOS related to discrepancies between outputfilename and name fields in the wails.json file.
  • Documentation
    • Updated changelog to reflect recent fixes and enhancements.

…veProjectData to export OutputFilename \n mod : modified CFBundleExecutable values to .OutputFilename in info.dev.plist, info.plist
Copy link
Contributor

coderabbitai bot commented Sep 28, 2024

Walkthrough

The changes involve modifications to the build configuration for macOS applications, specifically in the handling of executable names. The CFBundleExecutable key in the Info.plist and Info.dev.plist files has been updated to use {{.OutputFilename}} instead of {{.Name}}. Additionally, a new field, OutputFilename, has been added to the assetData struct in the buildassets.go file to support this change. A corresponding entry has also been added to the changelog to document a fix for a build error related to this issue.

Changes

Files Change Summary
v2/pkg/buildassets/build/darwin/Info.plist, v2/pkg/buildassets/build/darwin/Info.dev.plist Updated <key>CFBundleExecutable</key> value from {{.Name}} to {{.OutputFilename}}.
v2/pkg/buildassets/buildassets.go Added a new field OutputFilename to the assetData struct and updated its initialization.
website/src/pages/changelog.mdx Added a changelog entry for a fix related to build errors on macOS when name and outputfilename differ.

Assessment against linked issues

Objective Addressed Explanation
CFBundleExecutable should be set to 'outputfilename' (related to #3786)
The buildassets only exports 'Name' and 'Info' (related to #3786)

🐰 In the meadow, changes bloom,
With filenames that now make room.
From Name to OutputFilename we leap,
A fix for builds, a promise to keep!
Hopping forward, we celebrate,
For smoother builds, we can't wait! 🌼✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@nickisworking nickisworking marked this pull request as ready for review September 28, 2024 13:45
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Outside diff range and nitpick comments (1)
v2/pkg/buildassets/buildassets.go (1)

117-119: LGTM: Initialization of OutputFilename in resolveProjectData

The addition of OutputFilename: projectData.OutputFilename in the assetData initialization is correct and necessary to make the new field available for template resolution. This change, combined with the struct modification, effectively addresses the issue described in #3786.

Consider adding a validation check to ensure that projectData.OutputFilename is not empty before using it. This could prevent potential issues if the OutputFilename is not set in the project configuration. Here's a suggested implementation:

 data := &assetData{
 	Name:           projectData.Name,
 	Info:           projectData.Info,
-	OutputFilename: projectData.OutputFilename,
+	OutputFilename: projectData.OutputFilename,
+}
+
+if data.OutputFilename == "" {
+	return nil, fmt.Errorf("OutputFilename is not set in project data")
 }

This addition would make the function more robust against potential configuration errors.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 429e94f and 7b10da4.

📒 Files selected for processing (4)
  • v2/pkg/buildassets/build/darwin/Info.dev.plist (1 hunks)
  • v2/pkg/buildassets/build/darwin/Info.plist (1 hunks)
  • v2/pkg/buildassets/buildassets.go (2 hunks)
  • website/src/pages/changelog.mdx (1 hunks)
🔇 Additional comments (13)
v2/pkg/buildassets/build/darwin/Info.plist (2)

Line range hint 1-67: Additional files and changes to review

While the change in this file is crucial and correctly addresses the main issue, there are other important aspects of this PR that we haven't been able to review:

  1. The changes to assetData struct and resolveProjectData function mentioned in the PR summary.
  2. The update to the changelog as indicated in the PR checklist.
  3. The changes to info.dev.plist file, also mentioned in the PR summary.

To ensure a comprehensive review, it would be beneficial to examine these additional files and changes.

To locate the relevant files and changes, please run the following script:

#!/bin/bash
# Description: Locate relevant files and changes for the PR

# Search for assetData struct
echo "Searching for assetData struct:"
rg --type go 'type\s+assetData\s+struct' -A 10

echo -e "\nSearching for resolveProjectData function:"
rg --type go 'func\s+resolveProjectData' -A 10

echo -e "\nSearching for changelog updates:"
rg --type md 'fix.*error.*building.*runnable.*app.*MacOS' -g 'CHANGELOG.md'

echo -e "\nSearching for info.dev.plist file:"
fd 'info.dev.plist'

This will help us locate and review all the relevant changes for this PR.


9-9: Approved: Critical fix for macOS app bundle executable naming

This change correctly addresses the issue where the executable file was not generated properly when 'name' and 'outputfilename' differed. By using {{.OutputFilename}} instead of {{.Name}} for the CFBundleExecutable key, the Info.plist will now correctly reference the actual executable name, allowing the application to run as expected.

To ensure consistency across the project, please run the following script to check if similar changes are needed in other plist files, particularly info.dev.plist:

This will help us verify if the fix has been applied consistently across all relevant files.

v2/pkg/buildassets/build/darwin/Info.dev.plist (1)

9-9: Correct implementation to use OutputFilename

This change correctly implements the use of {{.OutputFilename}} instead of {{.Name}} for the CFBundleExecutable key. This aligns with the PR objective and should resolve the issue where the executable file was not generated correctly when 'name' and 'outputfilename' fields in wails.json were different.

To ensure consistency across the project, please run the following command to check if a similar change has been made in the Info.plist file:

If the command doesn't return a result, it might indicate that the Info.plist file needs a similar update.

v2/pkg/buildassets/buildassets.go (2)

105-107: LGTM: Addition of OutputFilename field to assetData struct

The addition of the OutputFilename field to the assetData struct is a good solution to address the issue described in #3786. This change allows for separate handling of the 'outputfilename' and 'name' values, which is crucial for fixing the build error on MacOS when these values differ.


Line range hint 1-146: Summary: Changes effectively address the build issue on MacOS

The modifications to v2/pkg/buildassets/buildassets.go successfully introduce support for handling 'outputfilename' separately from 'name'. These changes are crucial for resolving the build error on MacOS when these values differ, as described in issue #3786.

To ensure these changes have the intended effect across the codebase, please run the following verification script:

This script will help ensure that the OutputFilename is correctly used throughout the project, particularly in the info.plist files and any build scripts that might reference the executable name.

✅ Verification successful

Further Verification Needed: Expand Search for OutputFilename Usage

To ensure that all instances of OutputFilename are correctly handled across the codebase, please run the following verification scripts:

These scripts will help identify any additional usages of OutputFilename in various configuration and build script files, ensuring comprehensive verification of the changes.


Verification Successful: OutputFilename Properly Handled Across Codebase

The recent changes to v2/pkg/buildassets/buildassets.go correctly implement separate handling of OutputFilename, as evidenced by its proper usage in the Info.plist and Info.dev.plist files. No issues were found in other configuration or build script files.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of OutputFilename in template files and other relevant locations

# Test 1: Check if OutputFilename is used in info.plist files
echo "Checking info.plist files for OutputFilename usage:"
rg --type xml "OutputFilename" -g "*info*.plist"

# Test 2: Verify if there are any remaining instances where Name is used instead of OutputFilename for executable names
echo "Checking for potential missed Name usage instead of OutputFilename:"
rg --type xml "CFBundleExecutable.*Name" -g "*info*.plist"

# Test 3: Check other Go files for proper handling of OutputFilename
echo "Checking other Go files for OutputFilename handling:"
rg --type go "OutputFilename"

# Test 4: Verify if there are any build scripts that might need updating
echo "Checking build scripts for potential updates:"
rg "outputfilename" -g "*.sh" -g "*.bat" -g "*.ps1"

Length of output: 2658


Script:

#!/bin/bash
# Description: Comprehensive search for OutputFilename usage across all relevant files

# Test 1: Search for OutputFilename in any plist files
echo "Searching for OutputFilename in all plist files:"
rg "OutputFilename" -g "*.plist"

# Test 2: Search for OutputFilename in JSON configuration files
echo "Searching for OutputFilename in JSON files:"
rg "OutputFilename" -g "*.json"

# Test 3: Search for OutputFilename in YAML configuration files
echo "Searching for OutputFilename in YAML files:"
rg "OutputFilename" -g "*.yaml" -g "*.yml"

# Test 4: Search for OutputFilename in all build-related scripts without restricting file types
echo "Searching for OutputFilename in all build-related scripts (any script file):"
rg "OutputFilename" -g "*.sh" -g "*.bat" -g "*.ps1" -g "*.make" -g "*.build" -g "*.gradle" -g "*.xml"

Length of output: 853

website/src/pages/changelog.mdx (8)

34-35: New feature: Fixed file permissions for generated files

This change improves security and consistency by setting appropriate file permissions for generated files.


Line range hint 39-41: Multiple bug fixes and improvements

Several issues have been addressed, including fixes for the plain template, website layout, and Windows-specific problems.

🧰 Tools
🪛 LanguageTool

[grammar] ~31-~31: The correct preposition appears to be “on”.
Context: ...ps://github.com/mrf345) - Fixed dialogs in Windows when using Go 1.23 in [PR](http...

(IN_WINDOWS)


Line range hint 43-46: Changes to development workflow

The development process has been improved with changes to dependency installation and asset handling.

🧰 Tools
🪛 LanguageTool

[grammar] ~31-~31: The correct preposition appears to be “on”.
Context: ...ps://github.com/mrf345) - Fixed dialogs in Windows when using Go 1.23 in [PR](http...

(IN_WINDOWS)


Line range hint 1-7: Changelog format and versioning

The changelog follows the Keep a Changelog format and uses Semantic Versioning, which is a good practice for maintaining clear and consistent release notes.

🧰 Tools
🪛 LanguageTool

[grammar] ~31-~31: The correct preposition appears to be “on”.
Context: ...ps://github.com/mrf345) - Fixed dialogs in Windows when using Go 1.23 in [PR](http...

(IN_WINDOWS)


Line range hint 9-16: Changelog categories

The changelog uses standard categories (Added, Changed, Deprecated, Removed, Fixed, Security) which helps in quickly identifying the nature of changes.

🧰 Tools
🪛 LanguageTool

[grammar] ~31-~31: The correct preposition appears to be “on”.
Context: ...ps://github.com/mrf345) - Fixed dialogs in Windows when using Go 1.23 in [PR](http...

(IN_WINDOWS)


Line range hint 18-19: Latest version: v2.0.0

The changelog indicates that Wails has reached a major version 2.0.0, which likely includes significant changes or improvements.

🧰 Tools
🪛 LanguageTool

[grammar] ~31-~31: The correct preposition appears to be “on”.
Context: ...ps://github.com/mrf345) - Fixed dialogs in Windows when using Go 1.23 in [PR](http...

(IN_WINDOWS)


Line range hint 1-1639: Well-maintained and informative changelog

The Wails changelog is comprehensive, well-structured, and follows best practices for changelog maintenance. It provides clear information about new features, bug fixes, and breaking changes across versions, which is valuable for users and contributors.

🧰 Tools
🪛 LanguageTool

[grammar] ~31-~31: The correct preposition appears to be “on”.
Context: ...ps://github.com/mrf345) - Fixed dialogs in Windows when using Go 1.23 in [PR](http...

(IN_WINDOWS)


Line range hint 48-49: Deprecation notice: Fullscreen appoption

The Fullscreen application option is being deprecated in favor of WindowStartState.

#!/bin/bash
# Check for usage of deprecated Fullscreen option
grep -r "Fullscreen" . --include="*.go"
🧰 Tools
🪛 LanguageTool

[grammar] ~31-~31: The correct preposition appears to be “on”.
Context: ...ps://github.com/mrf345) - Fixed dialogs in Windows when using Go 1.23 in [PR](http...

(IN_WINDOWS)

Comment on lines 36 to 37
### Changed
- Modified docs to reflect the correct password syntax for the `gon-sign.json` file [PR](https://github.com/wailsapp/wails/pull/3620) by [@ignasbernotas](github.com/ignasbernotas)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

CSS Drag Detection Feature Not Implemented

The UseCSSDrag flag is set to true in the changelog files; however, there is no corresponding implementation in the codebase to enable CSS-based drag detection.

🔗 Analysis chain

New experimental feature: CSS Drag detection

This adds support for CSS-based drag detection, which could improve user interaction with draggable elements.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if the new CSS drag detection is properly implemented
grep -r "UseCSSDrag" .

Length of output: 5366


Script:

#!/bin/bash
# Verify if the new CSS drag detection is properly implemented
grep -rn "UseCSSDrag" .

Length of output: 878


Script:

#!/bin/bash
# Search for usage of UseCSSDrag in conditional statements or feature implementations
rg "UseCSSDrag" --context 2

Length of output: 3729

Copy link
Member

@leaanthony leaanthony left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for 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

Successfully merging this pull request may close these issues.

v2.9.2 can't build runnable .app on macOS when 'name' and 'outputfilename' are different
2 participants