We're getting a build error with Xcode 13 RC that ...
# multiplatform
m
We're getting a build error with Xcode 13 RC that was not there in Beta 5:
Copy code
Exception in thread "main" java.lang.Error: /var/folders/r8/cq5z9sk940sbz3kq52q5x4fx11kwqx/T/1091386677463552763.m:1:9: fatal error: could not build module 'SQLCipher'
at org.jetbrains.kotlin.native.interop.indexer.UtilsKt.ensureNoCompileErrors(Utils.kt:192)
at org.jetbrains.kotlin.native.interop.indexer.ModuleSupportKt.getModulesASTFiles(ModuleSupport.kt:68)
at org.jetbrains.kotlin.native.interop.indexer.ModuleSupportKt.getModulesInfo(ModuleSupport.kt:14)
at org.jetbrains.kotlin.native.interop.gen.jvm.MainKt.buildNativeLibrary(main.kt:531)
at org.jetbrains.kotlin.native.interop.gen.jvm.MainKt.processCLib(main.kt:268)
at org.jetbrains.kotlin.native.interop.gen.jvm.MainKt.interop(main.kt:76)
at org.jetbrains.kotlin.cli.utilities.InteropCompilerKt.invokeInterop(InteropCompiler.kt:45)
at org.jetbrains.kotlin.cli.utilities.MainKt.mainImpl(main.kt:38)
at org.jetbrains.kotlin.cli.utilities.MainKt.main(main.kt:60)

> Task :cinteropSQLCipherIos FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':cinteropSQLCipherIos'.
> Process 'command '/Library/Java/JavaVirtualMachines/jdk-15.0.2.jdk/Contents/Home/bin/java'' finished with non-zero exit value 1
There was no change to our code, the only difference is the Xcode update. Anyone had anything similar?
o
did you find anything?
m
@Osman Saral yes, thanks for reminding me! There is indeed a change in Xcode 13 RC and Final, which causes this behavior, BUT there is a workaround! This issue in the Kotlin issue tracker offers the following workaround:
Copy code
Workaround: add the following line to your cinterops in Gradle build script:
Copy code
compilerOpts("-DNS_FORMAT_ARGUMENT(A)=")
Copy code
Or just copy-paste these lines into your Gradle build script:
Copy code
tasks.withType(org.jetbrains.kotlin.gradle.tasks.CInteropProcess::class.java) {
    settings.compilerOpts("-DNS_FORMAT_ARGUMENT(A)=")
}
Copy code
A bit of explanation on what is going on.
In Xcode 13 RC localizedAttributedStringForKey:value:table: method got NS_FORMAT_ARGUMENT(1) macro attribute. Previously, this attribute was applicable only to functions that return a C string, CFString or NSString. Recently, Apple added support in Clang for another type, NSAttributedString. Clang that ships with Kotlin/Native does not have this patch and fails to process localizedAttributedStringForKey:value:table: declaration.
What this workaround does is it makes NS_FORMAT_ARGUMENT(1) a no-op. It is perfectly fine in this case since cinterop does not take this attribute into account anyway.
­čÖĆ 1