I'm trying the KMP/CMP setup within IntelliJ with ...
# multiplatform
o
I'm trying the KMP/CMP setup within IntelliJ with the incubating new Multiplatform plugin. I have a working project for Android, Desktop and recently iOS. When running the project from Xcode, it works. When running from IntelliJ using the Xcode app launcher, it launches but crashes right away.
Copy code
"/Users/.../Library/Caches/JetBrains/IdeaIC2025.1/DerivedData/MyApp-fgmdywopfclxqobcsnyttiffrkhx/Build/Products/Debug-iphonesimulator/MyApp.app"
Uncaught Kotlin exception: org.jetbrains.compose.resources.MissingResourceException: Missing resource with path: /Users/.../Library/Developer/CoreSimulator/Devices/5B4A74A8-04EE-4EE6-9249-2FB5E12CF7B8/data/Containers/Bundle/Application/E48DDD44-7B50-4301-AEA8-5EAEB29802EF/MyApp.app/compose-resources/composeResources/my.package.resources/values/strings.commonMain.cvr
This is a multimodular Gradle setup if that matters. I tried forcing res generation somehow without luck
Copy code
compose.resources {
    publicResClass = true
    packageOfResClass = "my.package.resources"
    generateResClass = always
}
Anyway, I have the feeling that the Xcode/iOS sim launcher doesn't build stuff like
embedAndSignAppleFrameworkForXcode
does and maybe not even building anything at all… What is the impact of
OVERRIDE_KOTLIN_BUILD_IDE_SUPPORTED=YES
in IntelliJ? I do have
my-module-shared/build/processedResources/iosSimulatorArm64/main/composeResources/my.package.resources/values/strings.commonMain.cvr
So, I guess this is a matter of packaging/moving stuff around in the final
.app
, but who is responsible for this? which task is not called?
Here are all
strings.commonMain.cvr
I can find
Copy code
./my-module-shared/build/generated/compose/resourceGenerator/assembledResources/iosSimulatorArm64Main/composeResources/my.package.resources/values/strings.commonMain.cvr
./my-module-shared/build/generated/assets/copyReleaseComposeResourcesToAndroidAssets/composeResources/my.package.resources/values/strings.commonMain.cvr
./my-module-shared/build/generated/assets/copyDebugComposeResourcesToAndroidAssets/composeResources/my.package.resources/values/strings.commonMain.cvr
./my-module-shared/build/processedResources/iosSimulatorArm64/main/composeResources/my.package.resources/values/strings.commonMain.cvr
./my-module-shared/build/kotlin-multiplatform-resources/assemble-hierarchically/iosSimulatorArm64ResolveSelfResources/composeResources/my.package.resources/values/strings.commonMain.cvr
./my-module-shared/build/kotlin-multiplatform-resources/aggregated-resources/iosSimulatorArm64/composeResources/my.package.resources/values/strings.commonMain.cvr
./my-module-shared/build/intermediates/assets/release/mergeReleaseAssets/composeResources/my.package.resources/values/strings.commonMain.cvr
./my-module-shared/build/intermediates/assets/debug/mergeDebugAssets/composeResources/my.package.resources/values/strings.commonMain.cvr
When creating a whole new project from scratch, when I launch the Xcode launcher from IntelliJ, it properly triggers the Gradle build
Copy code
Executing ':composeApp:embedAndSignAppleFrameworkForXcode'…
and I can see a bunch of other tasks like
syncComposeResourcesForIos
which is most likely what is missing on my side. For my project, when I launch the Xcode launcher, no Gradle task is triggered, why is so? What controls this? In the launcher, the configuration are similar between the 2 projects, and I have a "Build" dependency at bottom on both sides…
If I add specifically a Gradle task to the launcher in the "Before launch" section to trigger
embedAndSignAppleFrameworkForXcode
it fails telling me
Copy code
Could not infer iOS target architectures. Make sure to build via XCode (directly or via Kotlin Multiplatform Mobile plugin for Android Studio)
like it does in CLI The launcher do something under the hood, but what?! and why does it fail here?
I tried saving the launch config as project file to compare. The config are strictly indentical (except indentation, don't know why and obviously, the scheme & target names which are different). Interestingly, on my project, it suggested
.idea/runConfigurations/MyApp.xml
as output and on the other project, it was
.run/iosApp.run.xml
🤔
Ok, so it appears I finally have a minimal reproducer… I seems to be linked to the use of alternative
Configuration
like
Config.dev.xcconfig
. When the
PRODUCT_NAME
or
PRODUCT_BUNDLE_IDENTIFIER
diverge, it seems I get the issue. So, to reproduce, create a new project using the incubating wizard, only choose iOS. Add a string resource instead of hardcoded strings within app. Add a
Config.dev.xcconfig
near the default
Config.xcconfig
and reference it as a debug config in Xcode project for the
iosApp
configuration. It's still not 100% reproducible with this minimal repro setup, sometimes, changing the values of
Config.dev.xcconfig
is not enough, changing few times is enough to reproduce at some point though.
That being said, in my "real use case", I think it's still slightly different, no Gradle task is invoked at all, here, I seems I have it. I still don't understand who calls the Gradle tasks, when, how to control that… At least, having some logs of what happens between the IDE, Gradle, Xcode,
xcodebuild
would be nice.
I opened KMT-1320
thank you color 2
I also created KMT-1321 for Gradle not being called before running
xcodebuild
in my setup