I have a project using 2.4.0, and it’s throwing th...
# swift-export
g
I have a project using 2.4.0, and it’s throwing this:
Copy code
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':core-di:validateArchitecturesForEmbedAndSignAppleFrameworkForXcode' (registered in build file 'core-di/build.gradle.kts').
> Xcode Requested Architecture Not Configured in Gradle
    Xcode Requested Architecture Not Configured in Gradle
      Xcode requested target architectures that are not configured in your Gradle build: ios_x64.
      The framework 'core-di' cannot be built for these target architectures.
* Try:
> Add the missing Kotlin/Native target(s) to your kotlin {} block in build.gradle.kts
> Or exclude unsupported architectures in your Xcode project's Build Settings by setting EXCLUDED_ARCHS
> Run with --scan to get full insights from a Build Scan (powered by Develocity).
I’ve already set
EXCLUDED_ARCHS
and also
ONLY_ACTIVE_ARCH
to true, but still can’t make it build. The only workaround was adding the following to the build phases / build pre-action scripts:
Copy code
cd "$SRCROOT/.."
export ARCHS=$(echo "$ARCHS" | sed 's/x86_64//g' | xargs)
./gradlew ...
I’ve other projects using Kotlin 2.4.0 working without this workaround. Any hint? Unfortunately I can’t share a reproducible.
r
g
But it’s odd that some projects don’t require the extra
export ARCHS=$(echo "$ARCHS" | sed 's/x86_64//g' | xargs)
. KMP should simply ignore
x86_64
instead of throwing an error. I know those targets are being deprecated, but I’m only running into this issue now. Other projects targeting Kotlin 2.4.0 and
arm64
haven’t had this problem. In those cases, just setting
ONLY_ACTIVE_ARCH
was enough. 🤔
r
It's because you should remove it, since they are not supported anymore.
g
Remove it from where? My build.gradle files never ask for x86:
Copy code
listOf(iosArm64(), iosSimulatorArm64()).forEach { iosTarget -> ... }
r
you don't have it anywhere?
g
Nop
r
Maybe it's present in the iOS proj?
g
I’m using
ONLY_ACTIVE_ARCH
and since we have M chips, no x86_64 should be requested by the Xcode I believe.
can a SPM request it and override this setting? 🤔
r
I don't think so, but can't confirm
a
What's the value of "Architectures" field in the xcode project? This project relies on build phase, or pre build action? Do you use the new SPM Import? The crash happens on release or debug build?
g
> What’s the value of “Architectures” field in the xcode project? arm64 > This project relies on build phase, or pre build action? both (and the fix was added in both phases) > Do you use the new SPM Import? no, obj-c export > The crash happens on release or debug build? only tested with debug which is faster, would assume it’s the same for release.
a
both
Yes, xcode's prebuild action actually ignores architectures selected in the project 🙂 I feel like you have already reported this here: https://youtrack.jetbrains.com/issue/KT-86142#focus=Comments-27-13729000.0-0 ?
g
Damn, I was searching for that and I didn’t found 😅 I remember I had this… my bad
a
All good, no worries 🙂
🫶 1