Internal modifier | Internal functions and classes are not visible in Swift. |
JavaDoc comments | Some KDoc comments are visible if you add a special compiler argument. |
Exceptions and errors | Exceptions declared with @Throws are represented with NSError and must be handled. Not declared exceptions will cause a program termination. |
Collections with custom types data | Collections with elements of custom types do not require additional mappings. |
Collections with primitive types | Collections with elements of primitive types (except String) require a wrapper. |
Primitive types | May require mapping for integer data types and mapping for Char. |
Optional (nullable) primitive types | Some primitive types require mapping into special optional types. |
Mutable, immutable collections | To adjust mutability, the let and var keywords are used. Additional mappings are required for mutable collections. |
Unit and Nothing | The Unit and Nothing types can be used in the same way as in Kotlin: Unit as an object or void, Nothing cannot be created. |
Companion object | Access to functions and properties is available through the companion auxiliary object. |
Constructor with default arguments | You always have to specify all the arguments for a constructor. Improved interop available with SKIE. |
Extension function over platform class | A wrapper class appears with a method that accepts an object of the desired class. |
Extension properties for companion object of platform class | There is a property in the .h file, but in Swift it’s impossible to use. |
Extension properties for companion object of usual class | The property can be accessed through the companion object. |
Extension properties over platform class | A wrapper class appears with a function that accepts an object of the desired class. |
Extension properties over usual class | The property can be accessed through the class object. |
Function with default arguments | You always have to specify all the function arguments. Improved interop available with SKIE. |
Objects | Access is available through the shared auxiliary object. |
Top-level functions | A wrapper class appears: TopLevelFunctionKt.topLevelFunction(). |
Top-level val properties (readonly) | A wrapper class for accessing the property appears: TopLevelPropertyKt.topLevelProperty. |
Top-level var properties (mutable) | A wrapper class for accessing the property appears: TopLevelPropertyMutableKt.topLevelPropertyMutable. |
Usual class constructor | Works the same as Kotlin. |
Usual class function | Works the same as Kotlin. |
Usual class val property (readonly) | The property is accessible from the class object and is a readonly property. |
Usual class var property (mutable) | The property is accessible from the class object and is a mutable property. |
Abstract class | IDE has no hints to override abstract methods, rather we get a crash when trying to use the method during runtime. |
Annotation class | Annotations were not included in the .h file. |
Data class | Not all features of data classes are preserved, some are renamed. Improved interop available with SKIE. |
Enum class | Doesn't work as expected. But an object with static elements was generated. Improved interop available with SKIE. |
Inner class | Minor differences in creation syntax. |
Open class | Can inherit from open class, use its protected properties, override open, but not override final methods. |
Sealed class | A class with heirs is generated. Passing to a switch statement requires a default case. Improved interop available with SKIE. |
Inline class | The class was not included in the .h file and cannot be used. |
Fun interface | You can't create an anonymous class in Swift. |
Interface | The interface has become @protocol. But for some reason the val property turned into var. |
Sealed interface | Separate protocols were generated that were not related to each other. |
DSL | Functions with receivers have been generated, it doesn’t look as convenient as we would like. |
Function returns lambda | The function that returned the lambda works without crashes; lambda can be called. |
Function returns primitive type | A function returning a primitive type works without error. |
Function with extension function as args | The extension function turns into a lambda with a parameter. |
Function with lambda arguments | A function that takes one or more lambdas as arguments converts normally in Swift. |
Function with no return type | Functions that return nothing can be safely called. |
Function with value class parameter | The function appeared in the .h file, but the value class argument was turned into primitives. |
Function with vararg parameter | varargs are not mapped to Swift's variardic parameters, but instead to KotlinArray. |
Functions with overloads | There are some peculiarities when using the same parameter names. |
Inline functions | Inline functions are in the .h file, they can be called. |
Bounded generics | The generic type restriction doesn't work. |
Contravariant generics | Doesn't work as expected, you have to use a type cast. |
Covariant generics | Doesn't work as expected, you have to use a type cast. |
Generic classes | There are some features of using types. |
Generic functions | No automatic type inference, nullability features. |
Generic interfaces | Generic interfaces are not supported. |
Reified functions | The reified function crashes at runtime. |
Star projection | Doesn't work as expected, you have to use a type cast. |
Suspend functions | Translated into callback, experimentally - into async / await. Libraries like SKIE and KMP-NativeCoroutines can be used to improve the interop and provide cancellation support. |
Flows | Translated into callback, experimentally - into async / await. Generic type arguments are lost. Libraries like SKIE and KMP-NativeCoroutines can be used to improve the interop and provide cancellation support. |