Conversation
Release 0.27.0
Release 0.27.1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Depends on #894
Closes #848.
Closes #850.
Closes #863.
Resolved issues
Apple KLibs can now be compiled on Windows and Linux when Kotlin/Native
cross-compilation is otherwise supported. Bundle paths no longer contain the
Windows-invalid KLib
unique_name, and KLib packaging no longer requiresXcode tools.
projects using
com.android.kotlin.multiplatform.librarynow generate AndroidXML resources and Android
MRaccessors instead of JVM.propertiesfilesunder
res/.xcrunon Linux:PackAppleResourcesToKLibActionno longer invokesxcrun actool. Raw assetcatalogs are stored in the KLib and compiled only while linking the final
Apple framework or executable on macOS.
Summary
Enable Apple-target KLib compilation on Windows and Linux with Kotlin 2.2.20+
when the project is otherwise eligible for Kotlin/Native cross-compilation, and
support AGP's dedicated Kotlin Multiplatform Android library target.
Previously, Apple resource packaging had two host-specific problems:
unique_namewas used directly as the bundle directory name, so avalue such as
kotlin-2-tests:sharedfailed on Windows because:is not avalid file-name character;
PackAppleResourcesToKLibActioninvoked Xcode'sactoolduring KLibcompilation, although Xcode is only available on macOS.
This change makes KLib resource packaging host-independent and postpones asset
catalog compilation until the final Apple framework or executable is linked on
macOS.
It also supports AGP's dedicated Android KMP library target. That target reports
the Kotlin platform type as
jvm; moko-resources now recognizes the concretetarget as Android and selects the Android resource generator explicitly.
Changes
Android KMP library target support
KotlinMultiplatformAndroidLibraryTargetwhen thecom.android.kotlin.multiplatform.libraryplugin is applied.jvmplatform to moko-resources'androidJvmgenerator type.do not apply any Android plugin.
directory API, so resource packaging has an explicit task dependency.
Portable Apple bundle names
unique_nameas a file-system path component.CFBundleIdentifieras the bundle directory name. Theidentifier is derived from
<resourcesPackage>.<compilationName>, so thephysical name is deterministic, readable, and available from public plugin
configuration.
Info.plist.Example:
Host-independent KLib packaging
xcrun actoolfromPackAppleResourcesToKLibAction.Info.plist, localizations, files, and other resourceswith JVM APIs.
Assets.xcassetsin the Apple KLib without compiling it.Deferred macOS asset compilation
from the current module and dependency KLibs, then:
Assets.xcassetswithxcrun actool;Assets.carwas produced;with older KLibs that already contain
Assets.car.ProcessBuilderinvocation and include command output in afocused Gradle failure when
actoolfails.Automatic CocoaPods dummy-framework resources
An explicit user-provided
extraSpecAttributes["resource"]value still takesprecedence.
DummyFrameworkTaskwith placeholder bundledirectories, so CocoaPods sees resource bundles during
pod installbeforethe real framework can be linked.
<resourcesPackage>.mainidentifier;framework may depend on Pods that are unavailable until after
pod install.moko-resources placeholder marker; real or user-managed bundles are never
deleted.
DummyFrameworkTaskaction and manual CocoaPods resourceattribute from
samples/compose-resources-gallery.Apple platform mapping
Select the
actoolplatform from the Kotlin/Native link target instead ofalways using
iphoneos:actoolplatformiphoneosiphonesimulatormacosxappletvosappletvsimulatorwatchoswatchsimulatorThe configured iOS minimum deployment target is forwarded for iOS device and
simulator catalogs. Platform names and the deployment-target requirement are
represented by a dedicated enum rather than repeated string comparisons.
Regression coverage
target preservation.
samples/android-kmp-library, matching the Last version Not Work build error #850 configuration withGradle 8.13, Kotlin 2.2.20, and AGP 8.13.0.
check-android-kmp-libraryjob on macOS,Windows, and Linux and
assert that:
res/values/multiplatform_strings.xmland anR.stringaccessor;res/contains no JVM.propertiesfile;.propertiesbundle andClassLoaderaccessor.Info.plist,and Apple target mapping.
Assets.caris preservedwithout invoking
actool.unpacked-manifest file shape exposed by Kotlin/Native tasks.
preserving real bundle directories.
samples/kotlin-2-tests.:character;Assets.xcassetsand noAssets.car;Assets.carand no raw catalog.mavenLocal()has priority in the regression sample so CI exercisesthe plugin artifact built by the current workflow rather than a released
artifact with the same version.
Resulting build pipeline
Final Apple binaries still require macOS and Xcode. This change only makes the
library/KLib stage cross-platform, matching Kotlin 2.2.20 cross-compilation
capabilities.
Compatibility notes
CFBundleIdentifier.hardcode the previous
<project>:<module>.bundlepath must stop relying onthat name or use the predictable
<resourcesPackage>.<compilationName>.bundlename.Assets.carremain consumable.linking, and Apple tests are unchanged.
0.28.0 consumer plugin requirement
This requirement applies when a published KLib contains moko-resources images
or colors and another Gradle project consumes that KLib to link an Apple
framework or executable.
Before 0.28.0,
actoolran while the library KLib was being built. Thepublished KLib therefore contained a ready-to-use
Assets.car, and theconsumer plugin only needed to copy the bundle.
Starting with 0.28.0, the published KLib intentionally contains raw
Assets.xcassets. This is what makes the artifact publishable from Windows andLinux. This is a breaking KLib resource-format change when image or color
resources are present. The 0.28.0+ plugin performs the missing step in the
consuming macOS build:
Gradle plugins are not inherited transitively from library dependencies. A
library published with 0.28.0+ cannot automatically upgrade the plugin
used by the consuming application or shared module. The project that performs
the final Apple link must therefore apply moko-resources plugin 0.28.0 or a
newer compatible version.
If a plugin older than 0.28.0 consumes a 0.28.0+ KLib, it copies the bundle but
does not compile the embedded asset catalog. The final bundle can consequently contain
Assets.xcassetswithoutAssets.car. Strings, plurals, and raw files canstill be present, but images and colors backed by the asset catalog will not be
available through the normal Apple runtime lookup.
Compatibility matrix:
< 0.28.0containingAssets.car>= 0.28.0without image/color assets< 0.28.0>= 0.28.0containing rawAssets.xcassets< 0.28.0>= 0.28.0containing rawAssets.xcassets>= 0.28.0actoolruns during final linkingAssets.carThis is a build-tool compatibility requirement rather than a runtime API or
binary API change. It should be called out in the release notes as a minimum
consumer plugin version for libraries published with cross-compiled Apple
resources.
Verification
Completed locally on macOS:
./gradlew :resources-generator:checksamples/android-kmp-library/local-check.sh:core:assemblewith Android, JVM, iOS Arm64, iOS Simulator Arm64,and iOS x64 targets;
R.stringoutput and absence of.propertiesinAndroid
res/;.properties/ClassLoaderoutput;
samples/compose-jvm-apptarget API does not introduce an Android-plugin runtime requirement.
samples/compose-resources-galleryautomatic
shared.framework/*.bundleglob;verified the predictable current-module bundle name;
its KLib;
samples/kotlin-2-tests/local-check.shAssets.carassertions;samples/kotlin-2-samplecompileKotlinIosArm64with PNG, SVG, and color resources;linkDebugFrameworkIosArm64;CocoaPods, including the
copyFrameworkResourcesToAppbuild phase;Assets.xcassetsin the KLib and finalAssets.carin theframework and copied application bundle.
bash -n samples/kotlin-2-tests/local-check.sh.git diff --check.The dedicated
check-android-kmp-libraryworkflow job runs the sample onwindows-latest,ubuntu-latest, andmacOS-latest.