On iOS I’ve got `-Xobjc-generics` enabled. However...
# multiplatform
v
On iOS I’ve got
-Xobjc-generics
enabled. However when trying to run a release build I get:
cannot specialize non-generic type
Seems like Kotlin Generics are only working for debug builds. Is there any additional config needed?
k
Can you post your detailed config and error message in context?
v
Sorry it took me a bit longer. Using Kotlin 1.3.61:
Copy code
kotlin {
  def sdkName = System.getenv("SDK_NAME")
  if (sdkName != null && sdkName.startsWith("iphoneos")) {
    iosArm64("ios")
  } else {
    iosX64("ios")
  }

  cocoapods {
    summary = "BeCoachShared"
    homepage = "<https://becoach.app/>"
  }

  // When using cocoapods plugin we can't configure the Framework directly.
  targets.ios.binaries
      .findAll { it instanceof org.jetbrains.kotlin.gradle.plugin.mpp.Framework }
      .every {
        it.embedBitcode("YES".equals(System.getenv("ENABLE_BITCODE")) ? "bitcode" : "marker")
        it.setFreeCompilerArgs(it.getFreeCompilerArgs() + "-Xobjc-generics")
      }
}
When trying to run my iOS App for an iPhone 11 with a Debug Build Configuration everything works. When I switch to release I’m getting: ErrorHandling.swift7344: Cannot specialize non-generic type ‘SuccessFailure’ This is the generated class (Release Build Configuration):
Copy code
__attribute__((swift_name("SuccessFailure")))
@interface DatabaseSuccessFailure : KotlinBase
@end;
which obviously is missing the Type declaration. This is the generated class (Debug Build Configuration):
Copy code
__attribute__((swift_name("SuccessFailure")))
@interface DatabaseSuccessFailure<T> : KotlinBase
@end;
in Kotlin the class looks like this:
Copy code
// T : Any so that Swift understand that T can never be null.
sealed class SuccessFailure<T : Any>