https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
s

sirrah

02/05/2019, 7:56 AM
I'm in the process of upgrading a Kotlin Multiplatform project to Kotlin 1.3.20. I quickly ran into the following error while linking the
iosX64
target:
Copy code
ld: '/Users/.../.konan/dependencies/libffi-3.2.1-2-darwin-ios_sim/lib/libffi.a(ffi64_x86_64.o)' does not contain bitcode. You must rebuild it with bitcode enabled (Xcode setting ENABLE_BITCODE), obtain an updated library from the vendor, or disable bitcode for this target. for architecture x86_64
Which seems to be a result of bitcode being enabled by default in Kotlin 1.3.20. So I've tried disabling it for all my iOS targets by adding the following to each target:
Copy code
binaries {
   framework {
       embedBitcode('disable')
   }
}
Unfortunately this doesn't resolve the error. I'd appreciate any suggestions on what to try next?
s

svyatoslav.scherbina

02/05/2019, 7:59 AM
This should work. Can you show the entire Gradle script?
s

sirrah

02/05/2019, 8:08 AM
@svyatoslav.scherbina Thanks for taking a look. The iOS version of the project is reasonably barebones. It has a Gradle file in the root that configures the repositories and another Gradle file in the folder with the common Kotlin code.
s

svyatoslav.scherbina

02/05/2019, 8:29 AM
My experiments with your build scripts show that
embedBitcode
should fix the issue. Have you tried to do a clean rebuild?
s

sirrah

02/05/2019, 8:37 AM
Interesting, I did a clean rebuild, I even tried removing the
.gradle
dir and the build folders manually. But no change.
Could there be a build cache outside of the project folder? I'm not too familiar with the iOS build tools.
I've tried again after cleaning every cache I could think of,
.gradle
,
.konan
, llvm, xcode, but still no change.
s

svyatoslav.scherbina

02/05/2019, 9:11 AM
What task does report the report?
s

sirrah

02/05/2019, 9:14 AM
It happens while linking the iosX64 build (the simulator):
Copy code
./gradlew clean linkMainDebugFrameworkIosX64
i

ilya.matveev

02/05/2019, 10:49 AM
The root cause is that this build script creates two frameworks: one using the old
compilation.outputKinds
DSL method and another using the binaries DSL (
binaries { framework { ... } }
). And disabling bitcode embedding affects only the framework created by the binaries DSL. So you can just drop using
compilation.outputKinds
and use only the binaries DSL.
s

sirrah

02/05/2019, 11:03 AM
That makes a lot of sense! I've made the changes to my build file and the build is progressing again. Just a few more minutes for the build to complete...
Thanks a lot @ilya.matveev and @svyatoslav.scherbina, for both the solution and for taking the time!
👍 2
s

Sam

02/05/2019, 12:22 PM
FYI Xcode has two build caches and only one of them is erased during a clean operation. The other is called Derived Data. There’s a shortcut to navigate to it via the settings screen’s locations tab. On rare occasion when really weird errors are happening it’s because derived data has a bad cache of a framework. Deleting the contents of that directory will fix it.
s

sirrah

02/05/2019, 1:12 PM
@Sam Thanks Sam, I found that cache earlier on as well. After deleting it though it didn't get filled again. So that cache wasn't touched during the Kotlin build process.
s

Sam

02/05/2019, 2:12 PM
Interesting. It must be only for things that Xcode itself builds. If your project starts to pull in 3rd party libraries written in ObjC or Swift then you’ll need that directory one day. 👍
2 Views