Skip to content

refactor: improve resource directory handling for macOS #9038

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

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

beyondkmp
Copy link
Collaborator

@beyondkmp beyondkmp commented Apr 19, 2025

There are also locales files under the Electron frameworks on macOS. Deleting these can significantly reduce the app size.

The locales folders under Contents/Resources are all empty, so deleting them does not reduce the size.

It has already been tested in production, and deleting the locales files inside the Electron frameworks does not cause any issues.

…e language file deletion

- Updated `getResourcesDir` to simplify the logic for macOS and Electron-based frameworks.
- Introduced `getMacOsElectronFrameworkResourcesDir` to retrieve the correct resources path for Electron frameworks on macOS.
- Refactored language file deletion logic to handle multiple directories, enhancing the cleanup process for unused language files.
Copy link

changeset-bot bot commented Apr 19, 2025

🦋 Changeset detected

Latest commit: 4c34978

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 8 packages
Name Type
app-builder-lib Patch
dmg-builder Patch
electron-builder-squirrel-windows Patch
electron-builder Patch
electron-forge-maker-appimage Patch
electron-forge-maker-nsis-web Patch
electron-forge-maker-nsis Patch
electron-forge-maker-snap Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions bot added the mac label Apr 20, 2025
beyondkmp added a commit to beyondkmp/cherry-studio that referenced this pull request Apr 20, 2025
@beyondkmp beyondkmp requested a review from mmaietta April 23, 2025 09:25
@mmaietta
Copy link
Collaborator

mmaietta commented Apr 23, 2025

How does this reduce app size if "The locales folders under Contents/Resources are all empty, so deleting them does not reduce the size."?

Also, we already have electronLanguages that allows you to selectively choose what locales to package across all OS platforms.

@beyondkmp
Copy link
Collaborator Author

beyondkmp commented Apr 23, 2025

Sorry for the misunderstanding. Electron Builder currently only deletes the locales files under Contents/Resources in macOS, but these do not contain any locale files under lproj, so it does not reduce the size. To reduce the size, the locales files under Contents/Frameworks/Electron Framework.framework/Resources need to be deleted, as the actual locales files are located there in the framework.

image
image

@beyondkmp beyondkmp requested a review from mmaietta April 26, 2025 14:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
3 participants