### Configure Plugin Repositories Source: https://skie.touchlab.co/Installation Example of how to add mavenCentral() to your plugin repositories in settings.gradle.kts if the SKIE plugin is not found. ```gradle pluginManagement { repositories { google() mavenCentral() gradlePluginPortal() } } dependencyResolutionManagement { repositories { google() mavenCentral() } } ``` -------------------------------- ### Kotlin Default Arguments Example Source: https://skie.touchlab.co/features Example of a Kotlin function with a default argument. ```Kotlin fun sayHello(message: String = "Hello") { println(message) } ``` -------------------------------- ### Manual Conversion Example Source: https://skie.touchlab.co/features/flows Example of manually converting Flows when automatic conversion is not supported. ```Swift listOfFlows.map { SkieSwiftFlow(SkieKotlinFlow($0)) } ``` -------------------------------- ### Interface Extension Example (Kotlin) Source: https://skie.touchlab.co/features Demonstrates an interface extension in Kotlin. ```kotlin interface I class C : I fun I.interfaceExtension(i: Int): Int = i ``` -------------------------------- ### Kotlin Enum Example Source: https://skie.touchlab.co/features Example of a Kotlin enum. ```Kotlin enum class Turn { Left, Right } ``` -------------------------------- ### Kotlin StateFlow Example Source: https://skie.touchlab.co/features/flows Example of a Kotlin StateFlow with a List as its type argument. ```kotlin class ChatRoom { private val _messages = MutableStateFlow(emptyList()) val messages: StateFlow> = _messages // etc } ``` -------------------------------- ### Using annotations to enable/disable Flow interop Source: https://skie.touchlab.co/configuration Some examples of using annotations: ```kotlin import co.touchlab.skie.configuration.annotations.FlowInterop @FlowInterop.Enabled fun enabledFlow(): Flow = flowOf(1) @FlowInterop.Disabled fun disabledFlow(): Flow = flowOf(1) ``` -------------------------------- ### Enable Project Analytics with specific configuration Source: https://skie.touchlab.co/Analytics Example of how to enable Project analytics with specific configuration. ```kotlin skie { analytics { enabled.set(false) } additionalConfigurationFlags.add(SkieConfigurationFlag.Analytics_Project) } ``` -------------------------------- ### Enable Modules Analytics with specific configuration Source: https://skie.touchlab.co/Analytics Example of how to enable Modules analytics with specific configuration. ```kotlin skie { analytics { enabled.set(false) } additionalConfigurationFlags.add(SkieConfigurationFlag.Analytics_Modules) } ``` -------------------------------- ### Kotlin Sealed Class Example Source: https://skie.touchlab.co/features Example of a Kotlin sealed class. ```Kotlin sealed class Status { object Loading : Status() data class Error(val message: String) : Status() data class Success(val result: SomeData) : Status() } ``` -------------------------------- ### Overloaded Functions Example (Kotlin) Source: https://skie.touchlab.co/features Presents overloaded functions in Kotlin. ```kotlin fun foo(i: Int) { } fun foo(i: String) { } ``` -------------------------------- ### Swift with SKIE Default Arguments Example Source: https://skie.touchlab.co/features Example of calling a Kotlin function with default arguments from Swift using SKIE. ```Swift // calls sayHello(message: "Hello") sayHello() ``` -------------------------------- ### Enable Git Analytics with specific configuration Source: https://skie.touchlab.co/Analytics Example of how to enable Git statistics analytics with specific configuration. ```kotlin skie { analytics { enabled.set(false) } additionalConfigurationFlags.add(SkieConfigurationFlag.Analytics_Git) } ``` -------------------------------- ### SharedViewModel Example Source: https://skie.touchlab.co/features/flows-in-swiftui A Kotlin ViewModel demonstrating a Flow and a MutableStateFlow. ```kotlin class SharedViewModel { val counter = flow { var counter = 0 while (true) { emit(counter++) delay(1.seconds) } } val toggle = MutableStateFlow(false) } ``` -------------------------------- ### Enum Conversion Examples with SKIE Source: https://skie.touchlab.co/features/enums Examples of converting between Swift and Kotlin enums using SKIE's toKotlinEnum(), toSwiftEnum(), and casting. ```swift let turn: Turn = Turn.left // Conversion to Kotlin enum let kotlinEnum: __Turn = turn.toKotlinEnum() let kotlinEnum: __Turn = turn as __Turn // The original enum is prefixed with two underscores. // Conversion to Swift enum (turn == swiftEnum) let swiftEnum: Turn = kotlinEnum.toSwiftEnum() let swiftEnum: Turn = kotlinEnum as Turn ``` -------------------------------- ### Enable Gradle Performance Analytics with specific configuration Source: https://skie.touchlab.co/Analytics Example of how to enable Gradle Performance analytics with specific configuration. ```kotlin skie { analytics { enabled.set(false) } additionalConfigurationFlags.add(SkieConfigurationFlag.Analytics_GradlePerformance) } ``` -------------------------------- ### Swift with SKIE Enum Example Source: https://skie.touchlab.co/features Example of using a Kotlin enum with SKIE in Swift, demonstrating exhaustive switching. ```Swift func changeDirection(turn: Turn) { switch turn { case .left: goLeft() case .right: goRight() } } ``` -------------------------------- ### Kotlin Sealed Class Example Source: https://skie.touchlab.co/features/sealed An example of a Kotlin sealed class. ```kotlin sealed class Status { object Loading : Status() data class Error(val message: String) : Status() data class Success(val result: SomeData) : Status() } ``` -------------------------------- ### Explicitly Import Foundation Source: https://skie.touchlab.co/known-issues/missing-foundation Example of how to replace an import statement to include Foundation. ```swift import YourKotlinModuleName import Foundation ``` -------------------------------- ### Swift with SKIE Sealed Class Example Source: https://skie.touchlab.co/features Example of using a Kotlin sealed class with SKIE in Swift, including the `onEnum(of:)` function. ```Swift func updateStatus(status: Status) { switch onEnum(of: status) { case .loading: showLoading() case .error(let data): showError(message: data.message) case .success(let data): showResult(data: data.result) } } ``` -------------------------------- ### Example Global Function Returning Flow Source: https://skie.touchlab.co/features/combine Declare a global function helloWorld returning a Flow. ```kotlin fun helloWorld(): Flow { return flow { emit("Hello") delay(1.seconds) emit("World") delay(1.seconds) emit("!") } } ``` -------------------------------- ### Kotlin Property and Parameterless Function Example Source: https://skie.touchlab.co/features/overloaded-functions Example demonstrating a potential name collision in Swift between a Kotlin property and a parameterless function with the same name. ```kotlin fun foo(): Int = 1 val foo: Int = 1 ``` -------------------------------- ### Swift Signatures from Kotlin Value Class Example Source: https://skie.touchlab.co/features/overloaded-functions The resulting Swift signatures for the Kotlin value class example, highlighting the name collision that SKIE attempts to manage. ```swift func foo(v: Int32) func foo_(v: Int32) ``` -------------------------------- ### Type Casting Example Source: https://skie.touchlab.co/features/flows Demonstrates safe and unsafe type casting with SKIE Flow classes. ```Swift SkieKotlinFlow(swiftFlow) as! SkieKotlinFlow ``` ```Swift KotlinA().flow() as! SkieKotlinFlow ``` -------------------------------- ### Kotlin Value Class Example Source: https://skie.touchlab.co/features/overloaded-functions Example showing how value classes in Kotlin can lead to signature collisions in Swift when they wrap types that are also directly exposed. ```kotlin value class V(val value: Int) fun foo(v: V) { } fun foo(v: Int) { } ``` -------------------------------- ### Kotlin Global Function Source: https://skie.touchlab.co/features/global-functions An example of a global function defined in a Kotlin file. ```kotlin fun globalFunction(i: Int): Int = i ``` -------------------------------- ### Example Suspending Global Function Source: https://skie.touchlab.co/features/combine Declare a suspending global function helloWorld. ```kotlin suspend fun helloWorld(): String { return "Hello World!" } ``` -------------------------------- ### Add SKIE Gradle Plugin Source: https://skie.touchlab.co/Installation Apply the SKIE Gradle plugin to the build.gradle.kts file of the module that builds your Xcode Framework. ```gradle plugins { id("co.touchlab.skie") version "0.10.12" } ``` -------------------------------- ### Kotlin Enum Example Source: https://skie.touchlab.co/features/enums A simple Kotlin enum with two cases. ```kotlin enum class Turn { Left, Right } ``` -------------------------------- ### Disable Project Analytics Source: https://skie.touchlab.co/Analytics Example of how to disable Project analytics. ```kotlin skie { suppressedConfigurationFlags.add(SkieConfigurationFlag.Analytics_Project) } ``` -------------------------------- ### FileScopeConversion Enabled Gradle Configuration Source: https://skie.touchlab.co/configuration/functions Example of enabling FileScopeConversion using Gradle configuration in Kotlin DSL. ```gradle import co.touchlab.skie.configuration.FunctionInterop skie { features { group { FunctionInterop.FileScopeConversion.Enabled(true) // or false } } } ``` -------------------------------- ### Kotlin Enum Example Source: https://skie.touchlab.co/features/enums Example of a Kotlin data class and function that uses an enum, demonstrating a potential limitation with generics in Swift. ```kotlin data class ResultWrapper(val t: T) fun enumResult(): ResultWrapper { return ResultWrapper(Turn.Left) } ``` -------------------------------- ### Interface Extension Function Example Source: https://skie.touchlab.co/features/interface-extensions Demonstrates how SKIE simplifies calling interface extension functions from Swift compared to the non-SKIE approach. ```kotlin interface I class C : I fun I.foo(i: Int): Int = i ``` ```swift FileKt.foo(C(), i: 1) ``` ```swift C().foo(i: 1) ``` -------------------------------- ### Disable Modules Analytics Source: https://skie.touchlab.co/Analytics Example of how to disable Modules analytics. ```kotlin skie { suppressedConfigurationFlags.add(SkieConfigurationFlag.Analytics_Modules) } ``` -------------------------------- ### ExportEntireHierarchy Gradle Configuration Source: https://skie.touchlab.co/configuration/sealed Example of configuring the export of the entire sealed hierarchy in Gradle. ```kotlin import co.touchlab.skie.configuration.SealedInterop skie { features { group { SealedInterop.ExportEntireHierarchy(true) // or false } } } ``` -------------------------------- ### LegacyName Enabled Gradle Configuration Source: https://skie.touchlab.co/configuration/functions Example of enabling LegacyName using Gradle configuration in Kotlin DSL. ```gradle import co.touchlab.skie.configuration.FunctionInterop skie { features { group { FunctionInterop.LegacyName(true) // or false } } } ``` -------------------------------- ### Interface Extension Property Example Source: https://skie.touchlab.co/features/interface-extensions Illustrates how SKIE simplifies calling interface extension properties from Swift compared to the non-SKIE approach. ```kotlin var I.bar: Int get() = 1 set(value) {} ``` ```swift let c = C() let getValue = FileKt.bar(c) FileKt.setBar(c, value: 1) ``` ```swift let c = C() let getValue = c.bar c.bar = 1 ``` -------------------------------- ### Kotlin Suspend Function Example Source: https://skie.touchlab.co/features/suspend A sample Kotlin suspend function within a class. ```kotlin class ChatRoom { suspend fun send(message: String) { // Send a message } } ``` -------------------------------- ### Enabled (Boolean) - Gradle Configuration Source: https://skie.touchlab.co/configuration/default-arguments Example of configuring the default arguments feature using Gradle. ```Gradle import co.touchlab.skie.configuration.DefaultArgumentInterop skie { features { group { DefaultArgumentInterop.Enabled(true) // or false } } } ``` -------------------------------- ### FileScopeConversion Enabled Annotation Configuration Source: https://skie.touchlab.co/configuration/functions Example of enabling FileScopeConversion for global functions and interface extensions using Kotlin annotations. ```kotlin import co.touchlab.skie.configuration.annotations.FunctionInterop @FunctionInterop.FileScopeConversion.Enabled fun enabled() { } @FunctionInterop.FileScopeConversion.Disabled fun disabled() { } ``` -------------------------------- ### ExportEntireHierarchy Annotation Configuration Source: https://skie.touchlab.co/configuration/sealed Example of configuring the export of the entire sealed hierarchy using annotations. ```kotlin import co.touchlab.skie.configuration.annotations.SealedInterop @SealedInterop.EntireHierarchyExport.Enabled sealed interface EntireHierarchyExportEnabled @SealedInterop.EntireHierarchyExport.Disabled sealed interface EntireHierarchyExportDisabled ``` -------------------------------- ### Disable Gradle Performance Analytics Source: https://skie.touchlab.co/Analytics Example of how to disable Gradle Performance analytics. ```kotlin skie { suppressedConfigurationFlags.add(SkieConfigurationFlag.Analytics_GradlePerformance) } ``` -------------------------------- ### Suspend Function Example (Kotlin) Source: https://skie.touchlab.co/features A Kotlin suspend function within a class. ```kotlin class ChatRoom { suspend fun send(message: String) { // Send a message } } ``` -------------------------------- ### Function ParameterName Gradle Configuration Source: https://skie.touchlab.co/configuration/sealed Example of customizing the parameter name for the 'onEnum' function in Gradle. ```kotlin import co.touchlab.skie.configuration.SealedInterop skie { features { group { SealedInterop.Function.ParameterName("sealed2") } } } ``` -------------------------------- ### Gradle Configuration Source: https://skie.touchlab.co/configuration/warnings Example of configuring name collision warning suppression in Gradle (build.gradle.kts). ```kotlin import co.touchlab.skie.configuration.SuppressSkieWarning skie { features { group { SuppressSkieWarning.NameCollision(true) // or false } } } ``` -------------------------------- ### Case Visible Gradle Configuration Source: https://skie.touchlab.co/configuration/sealed Example of controlling the visibility of enum cases for subclasses in Gradle. ```kotlin import co.touchlab.skie.configuration.SealedInterop skie { features { group { SealedInterop.Case.Visible(true) // or false } } } ``` -------------------------------- ### Function Name Gradle Configuration Source: https://skie.touchlab.co/configuration/sealed Example of customizing the name of the generated 'onEnum' function in Gradle. ```kotlin import co.touchlab.skie.configuration.SealedInterop skie { features { group { SealedInterop.Function.Name("onEnum2") } } } ``` -------------------------------- ### MaximumDefaultArgumentCount (Int) - Gradle Configuration Source: https://skie.touchlab.co/configuration/default-arguments Example of configuring the maximum number of default arguments using Gradle. ```Gradle import co.touchlab.skie.configuration.DefaultArgumentInterop skie { features { group { DefaultArgumentInterop.MaximumDefaultArgumentCount(6) } } } ``` -------------------------------- ### Kotlin Overloaded Functions Source: https://skie.touchlab.co/features/overloaded-functions Example of two Kotlin functions with the same name but different parameter types, demonstrating Kotlin's support for function overloading. ```kotlin fun foo(i: Int) { } fun foo(i: String) { } ``` -------------------------------- ### Overriding Annotation Configuration Source: https://skie.touchlab.co/configuration Example of setting `overridesAnnotations` to `true` for a specific group to make Gradle configuration take precedence over annotations. ```kotlin import co.touchlab.skie.configuration.FlowInterop skie { features { group("co.touchlab.skie.types", overridesAnnotations = true) { FlowInterop.Enabled(false) } } } ``` -------------------------------- ### Enabled Gradle Configuration Source: https://skie.touchlab.co/configuration/sealed Example of configuring SKIE's sealed class interop feature in Gradle. ```kotlin import co.touchlab.skie.configuration.SealedInterop skie { features { group { SealedInterop.Enabled(true) // or false } } } ``` -------------------------------- ### Function ArgumentLabel Gradle Configuration Source: https://skie.touchlab.co/configuration/sealed Example of customizing the argument label for the 'onEnum' function parameter in Gradle. ```kotlin import co.touchlab.skie.configuration.SealedInterop skie { features { group { SealedInterop.Function.ArgumentLabel("of2") } } } ``` -------------------------------- ### ElseName Gradle Configuration Source: https://skie.touchlab.co/configuration/sealed Example of customizing the name of the 'else' case for hidden subclasses in Gradle. ```kotlin import co.touchlab.skie.configuration.SealedInterop skie { features { group { SealedInterop.ElseName("else2") } } } ``` -------------------------------- ### Annotation Configuration Source: https://skie.touchlab.co/configuration/warnings Example of suppressing name collision warnings using annotations in Kotlin. ```kotlin import co.touchlab.skie.configuration.annotations.SuppressSkieWarning @SuppressSkieWarning.NameCollision fun warningSuppressed() { } @SuppressSkieWarning.NameCollision(false) fun warningEnabled() { } ``` -------------------------------- ### LegacyName Enabled Annotation Configuration Source: https://skie.touchlab.co/configuration/functions Example of enabling LegacyName for function and property naming using Kotlin annotations. ```kotlin import co.touchlab.skie.configuration.annotations.FunctionInterop @FunctionInterop.LegacyName.Enabled fun enabled() { } @FunctionInterop.LegacyName.Disabled fun disabled() { } ``` -------------------------------- ### Enabled (Boolean) - Annotation Configuration Source: https://skie.touchlab.co/configuration/default-arguments Example of enabling and disabling the default arguments feature using annotations in Kotlin. ```Kotlin import co.touchlab.skie.configuration.annotations.DefaultArgumentInterop @DefaultArgumentInterop.Enabled fun enabled(i: Int = 0) { } @DefaultArgumentInterop.Disabled fun disabled(i: Int = 0) { } ``` -------------------------------- ### Function ParameterName Annotation Configuration Source: https://skie.touchlab.co/configuration/sealed Example of customizing the parameter name for the 'onEnum' function using annotations. ```kotlin import co.touchlab.skie.configuration.annotations.SealedInterop @SealedInterop.Function.ParameterName("sealed2") sealed interface HasCustomFunctionParameterName ``` -------------------------------- ### Case Visible Annotation Configuration Source: https://skie.touchlab.co/configuration/sealed Example of controlling the visibility of enum cases for subclasses using annotations. ```kotlin import co.touchlab.skie.configuration.annotations.SealedInterop sealed interface SealedInterface { @SealedInterop.Case.Visible object Visible : SealedInterface @SealedInterop.Case.Hidden object Hidden : SealedInterface } ``` -------------------------------- ### Function ArgumentLabel Annotation Configuration Source: https://skie.touchlab.co/configuration/sealed Example of customizing the argument label for the 'onEnum' function parameter using annotations. ```kotlin import co.touchlab.skie.configuration.annotations.SealedInterop @SealedInterop.Function.ArgumentLabel("of2") sealed interface HasCustomFunctionArgumentLabel ``` -------------------------------- ### Function Name Annotation Configuration Source: https://skie.touchlab.co/configuration/sealed Example of customizing the name of the generated 'onEnum' function using annotations. ```kotlin import co.touchlab.skie.configuration.annotations.SealedInterop @SealedInterop.Function.Name("onEnum2") sealed interface HasCustomFunctionName ``` -------------------------------- ### Enabled Annotation Configuration Source: https://skie.touchlab.co/configuration/sealed Example of enabling and disabling SKIE's sealed class interop using annotations. ```kotlin import co.touchlab.skie.configuration.annotations.SealedInterop @SealedInterop.Enabled sealed interface Enabled @SealedInterop.Disabled sealed interface Disabled ``` -------------------------------- ### ElseName Annotation Configuration Source: https://skie.touchlab.co/configuration/sealed Example of customizing the name of the 'else' case for hidden subclasses using annotations. ```kotlin import co.touchlab.skie.configuration.annotations.SealedInterop @SealedInterop.ElseName("else2") sealed interface HasCustomElseName ``` -------------------------------- ### Disable Flows only in a specific package Source: https://skie.touchlab.co/configuration The Gradle configuration can be applied more selectively. The `group` block takes an optional string argument, which matches a prefix of the fully qualified name of declarations like classes or functions. This prefix can be, for example, used to specify a package or a class. ```kotlin import co.touchlab.skie.configuration.FlowInterop skie { features { group("co.touchlab.skie.types") { FlowInterop.Enabled(false) } } } ``` -------------------------------- ### DefaultArgumentsInExternalLibraries (Boolean) - Gradle Configuration Source: https://skie.touchlab.co/configuration/default-arguments Example of controlling whether default arguments are allowed for functions from external libraries using Gradle. ```Gradle skie { features { defaultArgumentsInExternalLibraries.set(true) // or false } } ``` -------------------------------- ### Enable SwiftUI Observing Preview Source: https://skie.touchlab.co/features/flows-in-swiftui Configuration to enable SwiftUI observing features in SKIE. ```kotlin skie { features { enableSwiftUIObservingPreview = true } } ``` -------------------------------- ### MaximumDefaultArgumentCount (Int) - Annotation Configuration Source: https://skie.touchlab.co/configuration/default-arguments Example of setting the maximum number of default arguments allowed in a function using annotations in Kotlin. ```Kotlin import co.touchlab.skie.configuration.annotations.DefaultArgumentInterop @DefaultArgumentInterop.MaximumDefaultArgumentCount(6) fun functionWithSixDefaultArguments(p1: Int = 0, p2: Int = 0, p3: Int = 0, p4: Int = 0, p5: Int = 0, p6: Int = 0) { } ``` -------------------------------- ### Hidden Sealed Class Subclass Example (Kotlin) Source: https://skie.touchlab.co/features/sealed Example of a Kotlin sealed class with an internal subclass. ```kotlin sealed class Status { object Loading : Status() internal data class Error(val message: String) : Status() data class Success(val result: SomeData) : Status() } ``` -------------------------------- ### Enable Flow Combine Convertor Preview Source: https://skie.touchlab.co/features/combine To enable the support for Combine.Publisher, add the following to your build.gradle.kts: ```kotlin skie { features { enableFlowCombineConvertorPreview = true } } ``` -------------------------------- ### Adding the Annotation dependency Source: https://skie.touchlab.co/configuration Before you can use the SKIE annotations, you'll need to add the following dependency to all modules in which you want to use them: ```kotlin val commonMain by sourceSets.getting { dependencies { implementation("co.touchlab.skie:configuration-annotations:0.10.12") } } ``` -------------------------------- ### Kotlin data class User Source: https://skie.touchlab.co/features/default-arguments A sample Kotlin data class named User. ```kotlin data class User( val name: String, val age: Int, ) ``` -------------------------------- ### Swift Usage of toPublisher() Source: https://skie.touchlab.co/features/combine In Swift, use the toPublisher() function to convert a Flow into a Combine.Publisher. ```swift let publisher = helloWorld().toPublisher() publisher.sink { value in // Value is a `String` type // Receives with a 1-second delay between them: // - "Hello" // - "World" // - "!" } ``` -------------------------------- ### Enable Future Combine Extension Preview Source: https://skie.touchlab.co/features/combine To enable the support for Combine.Future, add the following to your build.gradle.kts: ```kotlin skie { features { enableFutureCombineExtensionPreview = true } } ``` -------------------------------- ### Enable specific analytics (build.gradle.kts) Source: https://skie.touchlab.co/Analytics This code shows how to only send the SKIE Performance analytics and nothing else. ```kotlin skie { analytics { enabled.set(false) } additionalConfigurationFlags.add(SkieConfigurationFlag.Analytics_SkiePerformance) } ``` -------------------------------- ### Observing Flows with Initial Content View Source: https://skie.touchlab.co/features/flows-in-swiftui Using the `Observing` SwiftUI view with an initial content view closure to handle flows without initial values. ```swift struct ExampleView: View { let viewModel = SharedViewModel() var body: some View { // Observing multiple flows with a "initial content" view closure. Observing(viewModel.counter, viewModel.toggle) { ProgressView("Waiting for counters to flows to produce a first value") } content: { counter, toggle in Text("Counter: \(counter), Toggle: \(toggle)") } } } ``` -------------------------------- ### Enabling just Gradle Environment analytics Source: https://skie.touchlab.co/Analytics Configuration to enable just the Gradle Environment analytics category. ```kotlin skie { analytics { enabled.set(false) } additionalConfigurationFlags.add(SkieConfigurationFlag.Analytics_GradleEnvironment) } ``` -------------------------------- ### Interface Extension Call (Swift with SKIE) Source: https://skie.touchlab.co/features Illustrates calling a Kotlin interface extension from Swift using SKIE. ```swift C().interfaceExtension(i: 1) ``` -------------------------------- ### Enable SKIE Configuration Analytics Source: https://skie.touchlab.co/Analytics Enables analytics for SKIE configuration. ```kotlin skie { analytics { enabled.set(false) } additionalConfigurationFlags.add(SkieConfigurationFlag.Analytics_SkieConfiguration) } ``` -------------------------------- ### Enable Compiler Configuration Analytics Source: https://skie.touchlab.co/Analytics Enables analytics for the compiler configuration. ```kotlin skie { analytics { enabled.set(false) } additionalConfigurationFlags.add(SkieConfigurationFlag.Analytics_CompilerConfiguration) } ``` -------------------------------- ### Observing Multiple Flows with Initial Values Source: https://skie.touchlab.co/features/flows-in-swiftui Using the `Observing` SwiftUI view to observe multiple StateFlows with initial values. ```swift struct ExampleView: View { let viewModel = SharedViewModel() var body: some View { // Observing multiple flows with attached initial values, only requiring a single view closure for content. Observing(viewModel.counter.withInitialValue(0), viewModel.toggle) { counter, toggle in Text("Counter: \(counter), Toggle: \(toggle)") } } } ``` -------------------------------- ### Swift code bundling enabled Source: https://skie.touchlab.co/configuration/swift-code-bundling Controls whether the Swift code bundling is enabled for the given module. The default value is `true`. ```gradle skie { swiftBundling { enabled = false // or true } } ``` -------------------------------- ### SwiftUI Task Modifier for Flow Cancellation Source: https://skie.touchlab.co/features/flows Example of using a task modifier to handle the cancellation of a Flow collection in Swift. ```swift VStack { // SwiftUI views .. } .task { await viewModel.activate() } ``` -------------------------------- ### Interface Extension Call (Swift without SKIE) Source: https://skie.touchlab.co/features Shows how to call a Kotlin interface extension from Swift without SKIE. ```swift FileKt.interfaceExtension(C(), i: 1) ``` -------------------------------- ### Swift with SKIE Source: https://skie.touchlab.co/features/overloaded-functions Demonstrates how SKIE allows the overloaded Kotlin functions to retain their original names in Swift, resolving name collisions effectively. ```swift foo(i: 1) foo(i: "A") ``` -------------------------------- ### Gradle configuration to specify cinterop framework name Source: https://skie.touchlab.co/known-issues/cinterop This `build.gradle.kts` snippet shows how to configure the framework name for a specific cinterop module ('co.touchlab.crashkios.bugsnag') using SKIE's configuration. ```gradle import co.touchlab.skie.configuration.ClassInterop skie { features { group("co.touchlab.crashkios.bugsnag") { ClassInterop.CInteropFrameworkName("Bugsnag") } } } ``` -------------------------------- ### Swift with SKIE - Exhaustive Switching Source: https://skie.touchlab.co/features/enums Example of Swift switch statement with SKIE, where the default case is no longer required due to exhaustive checking. ```swift func changeDirection(turn: Turn) { switch turn { case .left: goLeft() case .right: goRight() case .neither: noChange() } } ``` -------------------------------- ### Enable Compiler Environment Analytics Source: https://skie.touchlab.co/Analytics Enables analytics for the compiler environment. ```kotlin skie { analytics { enabled.set(false) } additionalConfigurationFlags.add(SkieConfigurationFlag.Analytics_CompilerEnvironment) } ``` -------------------------------- ### Produce Distributable Framework Source: https://skie.touchlab.co/configuration/swift-compiler Configures SKIE to produce a distributable framework, enabling Swift library evolution, disabling Clang module breadcrumbs in static frameworks, and enabling relative source paths in debug symbols. ```kotlin skie { build { produceDistributableFramework() } } ``` -------------------------------- ### Swift without SKIE - Default Case Required Source: https://skie.touchlab.co/features/enums Example of Swift switch statement for a Kotlin enum without SKIE, requiring a default case. ```swift func changeDirection(turn: Turn) { switch turn { case .left: goLeft() case .right: goRight() default: startOver() } } ``` -------------------------------- ### Swift Usage of Future Initializer Source: https://skie.touchlab.co/features/combine In Swift, use the new Future initializer to convert a suspend function into a Combine.Future. ```swift let future = Future(async: helloWorld) future.sink { error in // Handle an error throw by the function. // Note that this could also be `CancellationError`. } receiveValue: { value in // Value is a `String` "Hello World!" print(value) } ``` -------------------------------- ### Kotlin copy method with default arguments Source: https://skie.touchlab.co/features/default-arguments The automatically generated copy method for the User data class, demonstrating default arguments in Kotlin. ```kotlin fun User.copy(name: String = this.name, age: Int = this.age) = User(name, age) ``` -------------------------------- ### Refresh Gradle Dependencies Source: https://skie.touchlab.co/known-issues/gradle-cache Command to refresh Gradle dependencies to resolve caching issues. ```bash ./gradlew dependencies --refresh-dependencies ``` -------------------------------- ### Suspend Function Call (Swift with SKIE) Source: https://skie.touchlab.co/features Illustrates calling a Kotlin suspend function from Swift using SKIE, demonstrating async/await and cancellation. ```swift let chatRoom = ChatRoom() let task = Task.detached { // Runs on a background thread try? await chatRoom.send(message: "some message") } // Cancellation of the task also cancels the Kotlin coroutine task.cancel() ``` -------------------------------- ### Flows Gradle Configuration Source: https://skie.touchlab.co/configuration/coroutines Configures the Flows feature globally via Gradle. ```kotlin import co.touchlab.skie.configuration.FlowInterop skie { features { group { FlowInterop.Enabled(true) // or false } } } ``` -------------------------------- ### Disable Flows everywhere except for a specific package Source: https://skie.touchlab.co/configuration But what if you want to disable Flows everywhere except for the `co.touchlab.skie.types` package? In that case, you can use multiple groups to override the configuration selectively: ```kotlin import co.touchlab.skie.configuration.FlowInterop skie { features { group { FlowInterop.Enabled(false) } group("co.touchlab.skie.types") { FlowInterop.Enabled(true) } } } ``` -------------------------------- ### CoroutinesInterop Gradle Configuration Source: https://skie.touchlab.co/configuration/coroutines Globally enables or disables support for all coroutines interop features via Gradle. ```kotlin skie { features { coroutinesInterop.set(true) // or false } } ``` -------------------------------- ### Enable Swift Library Evolution Source: https://skie.touchlab.co/configuration/swift-compiler Explicitly enables Swift library evolution, which is necessary for binary compatibility of distributed Frameworks. This is often required when building XCFrameworks. ```kotlin skie { build { enableSwiftLibraryEvolution.set(true) } } ``` -------------------------------- ### Swift without SKIE Source: https://skie.touchlab.co/features/overloaded-functions Illustrates how the two Kotlin functions would be called in Swift without SKIE, showing name mangling due to Objective-C's overloading limitations. ```swift foo(i: 1) foo(i_: "A") ``` -------------------------------- ### Swift Call with SKIE Source: https://skie.touchlab.co/features/global-functions How the same Kotlin global function can be called from Swift using SKIE, resulting in a simpler, direct global function call. ```swift globalFunction(i: 1) ``` -------------------------------- ### Disable specific analytics (build.gradle.kts) Source: https://skie.touchlab.co/Analytics This code shows how to send all data except the Git statistics. ```kotlin skie { suppressedConfigurationFlags.add(SkieConfigurationFlag.Analytics_Git) } ``` -------------------------------- ### Swift Call without SKIE Source: https://skie.touchlab.co/features/global-functions How the Kotlin global function would be called from Swift without using SKIE, requiring the namespace derived from the file name. ```swift FileKt.globalFunction(i: 1) ``` -------------------------------- ### Enable Relative Source Paths in Debug Symbols Source: https://skie.touchlab.co/configuration/swift-compiler Enables relative source paths in debug information. This allows frameworks to be distributed and debugged on other computers without debugger configuration issues, by working around a bug in the Kotlin compiler. ```kotlin skie { build { enableRelativeSourcePathsInDebugSymbols.set(true) } } ```