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 configureNativeApplication.kt to pass Compose resource directories from Kotlin Native binaries to the packaging task.
  • Resources are now copied into the .app/Contents/Resources directory for packaged macOS applications.
  • 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]

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.

@MatkovIvan MatkovIvan requested a review from terrakok September 16, 2025 12:06
@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 😄).

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

Key changes:
- Added `composeResourcesDirs` property to `AbstractNativeMacApplicationPackageAppDirTask` to include resources during app packaging.
- Updated `configureNativeApplication.kt` to pass Compose resource directories from Kotlin Native binaries to the packaging task.
- Included a new test project `misc/macosNativeResources` to verify the integration.
- Added `macosExecutableResources` test in `ResourcesTest.kt` to ensure resources are correctly packaged into the `.app` bundle.
@Sanlorng Sanlorng force-pushed the update_mac_os_package branch from 5d36c32 to 1b9547c Compare September 18, 2025 12:57
@Sanlorng
Copy link
Author

I have reverterd all the previous changes and rewritten the function.

This commit changes the type of `composeResourcesDirs` in `AbstractNativeMacApplicationPackageAppDirTask` from `ListProperty<SourceDirectorySet>` to `Property<FileCollection?>`.

This change simplifies the configuration of native application packaging by directly using `project.files` to gather resource directories from Kotlin source sets.
@Sanlorng Sanlorng requested a review from terrakok September 18, 2025 13:07
…ackageAppDirTask` was changed from `Property<FileCollection?>` to `ConfigurableFileCollection`.
@Sanlorng
Copy link
Author

Is there anything else that needs to be changed?

1 similar comment
@Sanlorng
Copy link
Author

Is there anything else that needs to be changed?

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