Skip to content

Conversation

Sanlorng
Copy link

@Sanlorng Sanlorng commented Sep 16, 2025

Support for Compose Resources in native macOS executables.

  • Added a new integration test macosExecutableResources to verify resource copying for macOS executables.
  • Updated IosResources.kt to handle resource copying for Executable binaries on macOS.
  • Resources are now copied into the .app/Contents/Resources directory for packaged macOS applications.
  • The copyExecutableComposeResourcesFor[Target] task is now configured for macOS executables.
  • Packaging tasks for macOS now depend on the corresponding resource copying task.

Testing

Executing tasks: [:compose:test-Gradle(9.0.0)-Agp(8.9.0), --tests, org.jetbrains.compose.test.tests.integration.ResourcesTest.macosExectuableResources]
Executing tasks: [:compose:test-Gradle(9.0.0)-Agp(8.9.0), --tests, org.jetbrains.compose.test.tests.integration.ResourcesTest.macosTestResources]

Release Notes

Fixes - macOS Native

  • (prerelease fix) Fixed an issue where resources were not copied when packaging the macOS native target, causing the application to crash when it attempted to read those resources.

This commit introduces support for Compose Resources in native macOS executables.

- Added a new integration test `macosExecutableResources` to verify resource copying for macOS executables.
- Updated `IosResources.kt` to handle resource copying for `Executable` binaries on macOS.
- Resources are now copied into the `.app/Contents/Resources` directory for packaged macOS applications.
- The `copyExecutableComposeResourcesFor[Target]` task is now configured for macOS executables.
- Packaging tasks for macOS now depend on the corresponding resource copying task.
@MatkovIvan MatkovIvan requested a review from terrakok September 16, 2025 12:06
This commit introduces a new test project `misc/macosNativeResources` to verify the functionality of Compose resources in macOS native applications.

The test project includes:
- A simple Composable `App` that displays an image resource.
- Vector drawable resources for the app icon and an image.
- Gradle configuration for building a macOS native application (`.dmg`).
- A `main.kt` for the macOS target.
- `gradle.properties` to enable experimental macOS features.
- `settings.gradle.kts` for project setup.

The existing `ResourcesTest.kt` is updated to use this new test project for `macosExecutableResources` test, replacing the previous in-memory modification of the `misc/appleResources` project.

This change allows for a more isolated and maintainable test for macOS native resources.
@Sanlorng Sanlorng requested a review from terrakok September 16, 2025 14:56
@terrakok
Copy link
Member

I revisited the codebase and decided the feature should be done in configureNativeApplication function.

Could you refactor it?

@Sanlorng
Copy link
Author

I revisited the codebase and decided the feature should be done in configureNativeApplication function.

Could you refactor it?

Ok

@Sanlorng
Copy link
Author

I revisited the codebase and decided the feature should be done in configureNativeApplication function.

Could you refactor it?

Should i keep the copyComposeResourcesForNativeExecutable function in the iosResources.kt file ?

@terrakok
Copy link
Member

Better to revert all changes. Because the file is related to ios specifics (yes, it helps with macos unit tests, as I see, but by chance 😄).

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.

2 participants