Slide 1

Slide 1 text

2025/11/1 Kotlin Fest 2025 @giginet Inside of Swift Export KotlinͱSwiftΛܨ͙৽͍͠࢓૊Έ

Slide 2

Slide 2 text

• X/GitHub : @giginet • LINEϠϑʔגࣜձࣾ • LINE iOSΞϓϦͷϏϧυγεςϜվળ΍ɺ։ൃऀͷͨΊͷπʔϧ։ ൃΛ͍ͯ͠·͢ • αʔόʔαΠυKotlin΋΍͍ͬͯ·͢ • Kotlin Fest͸ॳొஃ Self Introduction

Slide 3

Slide 3 text

No content

Slide 4

Slide 4 text

,PUMJO͔Β σϑΥϧτ༗ޮԽ

Slide 5

Slide 5 text

Swift Export • Kotlin 2.1.0͔Βར༻Մೳʹͳͬͨ৽͍͠Kotlin -> Swiftͷ interoperability(interop) • 2.2.20͔ΒσϑΥϧτ༗ޮԽ • ैདྷɺSwift͔Β͸Kotlinͷ࣮૷͕Objective-Cͱ͔ͯ͠͠ݟ͑ͳ͔͕ͬͨɺ௚ ઀Swiftͱͯ͠ѻ͑ΔΑ͏ʹͳͬͨ

Slide 6

Slide 6 text

Agenda • ैདྷͷSwift Interoperability - Objective-C Export • ࢓૊Έͱ໰୊఺ • ৽͍͠Interoperability - Swift Export • ͳʹ͕Ͱ͖ΔΑ͏ʹͳͬͨͷ͔ • Ͳ͏΍ͬͯಈ࡞͍ͯ͠Δͷ͔ • ࠓޙͷϩʔυϚοϓ

Slide 7

Slide 7 text

ैདྷͷSwift Interoperability • Objective-C Export • Kotlin NativeͷϏϧυγεςϜͰϏϧυ • KotlinͷωΠςΟϒόΠφϦΛObjCܦ༝Ͱࢀরͯ͠ɺͦΕΛSwift͔ΒಡΈࠐΈ • ͦͷաఔͰObjCͷݴޠػೳͷΈʹ੍໿ɻදݱྗ͕ࣦΘΕΔ KOTLIN Objective-C

Slide 8

Slide 8 text

fun fibonacci(n: Int): Int = if (n <= 1) n else fibonacci(n - 1) + fibonacci(n - 2)

Slide 9

Slide 9 text

fun fibonacci(n: Int): Int = if (n <= 1) n else fibonacci(n - 1) + fibonacci(n - 2) __attribute__((objc_subclassing_restricted)) __attribute__((swift_name("FunctionsKt"))) @interface MOCFFunctionsKt : OCEDBase + (int32_t)fibonacciN:(int32_t)n __attribute__((swift_name("fibonacci(n:)"))); @end

Slide 10

Slide 10 text

fun fibonacci(n: Int): Int = if (n <= 1) n else fibonacci(n - 1) + fibonacci(n - 2) __attribute__((objc_subclassing_restricted)) __attribute__((swift_name("FunctionsKt"))) @interface MOCFFunctionsKt : OCEDBase + (int32_t)fibonacciN:(int32_t)n __attribute__((swift_name("fibonacci(n:)"))); @end import MyObjCFramework FunctionsKt.fibonacci(n: 10)

Slide 11

Slide 11 text

data class Vector( val x: Double, val y: Double, ) { operator fun plus(other: Vector): Vector = Vector(x + other.x, y + other.y) }

Slide 12

Slide 12 text

__attribute__((objc_subclassing_restricted)) __attribute__((swift_name("Vector"))) @interface MOCFVector : MOCFBase - (OCEDVector *)plusOther:(OCEDVector *)other __attribute__((swift_name("plus(other:)"))); @end data class Vector( val x: Double, val y: Double, ) { operator fun plus(other: Vector): Vector = Vector(x + other.x, y + other.y) }

Slide 13

Slide 13 text

__attribute__((objc_subclassing_restricted)) __attribute__((swift_name("Vector"))) @interface MOCFVector : MOCFBase - (OCEDVector *)plusOther:(OCEDVector *)other __attribute__((swift_name("plus(other:)"))); @end let a = Vector(x: 10, y: 20) let b = Vector(x: 15, y: 25) a.plus(other: b) data class Vector( val x: Double, val y: Double, ) { operator fun plus(other: Vector): Vector = Vector(x + other.x, y + other.y) }

Slide 14

Slide 14 text

ObjCΛܦ༝ͨ͠interopͷ໰୊఺ • Kotlinͷදݱྗͷଟ͕ࣦ͘ΘΕΔ • ϞδϡʔϧɾωʔϜεϖʔε • ΦʔόʔϩʔυɺԋࢉࢠΦʔόʔϩʔυ • δΣωϦΫε • PrimitiveܕͷίϨΫγϣϯͷѻ͍ • async-await

Slide 15

Slide 15 text

KOTLIN

Slide 16

Slide 16 text

KOTLIN C Header Native Library Build

Slide 17

Slide 17 text

KOTLIN MyLibrary.framework C Header Native Library Build

Slide 18

Slide 18 text

KOTLIN MyLibrary.framework C Header Native Library Build Link

Slide 19

Slide 19 text

ObjCExportDemo.framework

Slide 20

Slide 20 text

ObjC ExportͷϏϧυγεςϜͷ໰୊఺ • ϏϧυγεςϜ͕ෳࡶͰॊೈੑ͕ͳ͍ • Apple FrameworkܗࣜͰόΠφϦͱͯ͠ు͖ग़͞ΕΔͨΊɺSwiftଆͷIDE͔ ΒऔΓճͮ͠Β͍ • SwiftίϯύΠϥ͕ղऍͰ͖ΔόΠφϦͷੜ੒·ͰΛKotlin NativeίϯύΠϥ ͕୲͏ͨΊෳࡶͰີ݁߹

Slide 21

Slide 21 text

No content

Slide 22

Slide 22 text

Swift Export

Slide 23

Slide 23 text

KOTLIN Objective-C Objective-C Export

Slide 24

Slide 24 text

KOTLIN Swift Export

Slide 25

Slide 25 text

kotlin { swiftExport { moduleName = “MySwiftFramework" } }

Slide 26

Slide 26 text

./gradlew :embedSwiftExportForXcode

Slide 27

Slide 27 text

Kotlin/swift-export-sample

Slide 28

Slide 28 text

fun fibonacci(n: Int): Int = if (n <= 1) n else fibonacci(n - 1) + fibonacci(n - 2)

Slide 29

Slide 29 text

fun fibonacci(n: Int): Int = if (n <= 1) n else fibonacci(n - 1) + fibonacci(n - 2) import MySwiftFramework fibonacci(n: 10)

Slide 30

Slide 30 text

package com.github.jetbrains.modulea class ClassFromA(private val name: String) { fun hello(): String { return "Hello from $name" } }

Slide 31

Slide 31 text

package com.github.jetbrains.modulea class ClassFromA(private val name: String) { fun hello(): String { return "Hello from $name" } } import ModuleA import ModuleB let moduleA = ClassFromA("Alice") let moduleB = ClassFromB("Bob") print(moduleA.hello()) print(moduleB.hello())

Slide 32

Slide 32 text

data class Vector( val x: Double, val y: Double, ) { operator fun plus(other: Vector): Vector = Vector(x + other.x, y + other.y) }

Slide 33

Slide 33 text

data class Vector( val x: Double, val y: Double, ) { operator fun plus(other: Vector): Vector = Vector(x + other.x, y + other.y) } import Geometry let a = Vector(x: 10, y: 20) let b = Vector(x: 15, y: 25) let combined = a + b

Slide 34

Slide 34 text

Inside of Swift Export • ΞʔΩςΫνϟ͸ެࣜͷυΩϡϝϯτͰ঺հ͞Ε͍ͯΔ • https://github.com/JetBrains/kotlin/tree/master/docs/swift-export • Reference • Swift Export - a peek under the hood - Kotlin Conf 2025 • https://2025.kotlinconf.com/talks/798313/ • Swift Export: Natural Interoperability between Kotlin and Swift | by Santiago Mattiauda | Medium • https://medium.com/@santimattius/swift-export-natural-interoperability- between-kotlin-and-swift-720799961edc

Slide 35

Slide 35 text

https://github.com/JetBrains/kotlin/blob/master/docs/swift-export/architecture.md

Slide 36

Slide 36 text

https://github.com/JetBrains/kotlin/blob/master/docs/swift-export/architecture.md

Slide 37

Slide 37 text

data class Vector( val x: Double, val y: Double, ) { operator fun plus(other: Vector): Vector = Vector(x + other.x, y + other.y) }

Slide 38

Slide 38 text

Swift Export Pipeline 1. Analysis APIͰηϚϯςΟοΫΛղੳ 2. Swift IRͷੜ੒ 3. SirPrinter / BridgeGeneratorͰϒϦοδΛੜ੒͢Δ 4. Kotlin NativeίϯύΠϥ / SwiftίϯύΠϥͰϏϧυ

Slide 39

Slide 39 text

Swift Export Pipeline 1. Analysis APIͰηϚϯςΟοΫΛղੳ 2. Swift IRͷੜ੒ 3. SirPrinter / BridgeGeneratorͰϒϦοδΛੜ੒͢Δ 4. Kotlin NativeίϯύΠϥ / SwiftίϯύΠϥͰϏϧυ

Slide 40

Slide 40 text

Analysis API • K2 Compiler͕ఏڙ͢Δίʔυղੳͷ࢓૊Έ • Kotlinίʔυ͔Βܕ৘ใͳͲͷηϚϯςΟΫεΛ෼ੳ • ੩తղੳث(ktlint)΍υΩϡϝϯτੜ੒(dokka)ͳͲʹ΋ར༻͞Ε͍ͯΔ • K2ͷKotlin IDEϓϥάΠϯͷதΛ೷͍ͯΈΑ͏♪ - Kotlin Fest 2024 • https://2024.kotlinfest.dev/timetable/1719042600_a/

Slide 41

Slide 41 text

Swift Export Pipeline 1. Analysis APIͰηϚϯςΟοΫΛղੳ 2. Swift IRͷੜ੒ 3. SirPrinter / BridgeGeneratorͰϒϦοδΛੜ੒͢Δ 4. Kotlin NativeίϯύΠϥ / SwiftίϯύΠϥͰϏϧυ

Slide 42

Slide 42 text

Swift Export Pipeline 1. Analysis APIͰηϚϯςΟοΫΛղੳ 2. Swift IRͷੜ੒ 3. SirPrinter / BridgeGeneratorͰϒϦοδΛੜ੒͢Δ 4. Kotlin NativeίϯύΠϥ / SwiftίϯύΠϥͰϏϧυ

Slide 43

Slide 43 text

Swift Intermediate Representation (Sir) • Swift Exportಠࣗͷதؒදݱ • ࣮ମ͸Swift Export࣮૷಺ͷKotlinΦϒδΣΫτ

Slide 44

Slide 44 text

Swift Intermediate Representation (Sir) • Swift Exportಠࣗͷதؒදݱ • ࣮ମ͸Swift Export࣮૷಺ͷKotlinΦϒδΣΫτ data class Vector constructor(x: Kotlin.Double, y: Kotlin.Double) property x: Kotlin.Double property y: Kotlin.Double operator fun plus(other: Vector): Vector Analysis API

Slide 45

Slide 45 text

Swift Intermediate Representation (Sir) • Swift Exportಠࣗͷதؒදݱ • ࣮ମ͸Swift Export࣮૷಺ͷKotlinΦϒδΣΫτ data class Vector constructor(x: Kotlin.Double, y: Kotlin.Double) property x: Kotlin.Double property y: Kotlin.Double operator fun plus(other: Vector): Vector class Vector init(x: Swift.Double, y: Swift.Double) var x: Swift.Double var y: Swift.Double static func +(this: Vector, other: Vector) -> Vector Analysis API Sir

Slide 46

Slide 46 text

Swift Export Pipeline 1. Analysis APIͰηϚϯςΟοΫΛղੳ 2. Swift IRͷੜ੒ 3. SirPrinter / BridgeGeneratorͰϒϦοδΛੜ੒͢Δ 4. Kotlin NativeίϯύΠϥ / SwiftίϯύΠϥͰϏϧυ

Slide 47

Slide 47 text

Swift Export Pipeline 1. Analysis APIͰηϚϯςΟοΫΛղੳ 2. Swift IRͷੜ੒ 3. SirPrinter / BridgeGeneratorͰϒϦοδΛੜ੒͢Δ 4. Kotlin NativeίϯύΠϥ / SwiftίϯύΠϥͰϏϧυ

Slide 48

Slide 48 text

Bridgeͷੜ੒ • Sir͔ΒKotlin, Clang Header(C), Swiftͷ3ͭͷίʔυΛੜ੒͢Δ • Kotlin Function Bridge • Kotlin NativeͷόΠφϦΛૢ࡞͢ΔͨΊͷ௿ϨϕϧͳΠϯλʔϑΣΠε(ABI) • Swiftଆ͔Β౉͖ͬͯͨϙΠϯλΛKotlinΦϒδΣΫτʹม׵ͯ͠ૢ࡞͢Δϥού • C Header • Kotlin Function BridgeͰग़ྗ͞ΕͨABIΛCͷؔ਺ͱͯ͠ެ։ • Swift • Cͷؔ਺ΛϢʔβʔ͕ૢ࡞͠΍͍͢Α͏ʹSwiftͰϥοϓ

Slide 49

Slide 49 text

@ExportedBridge("Vector_x_get") public fun Vector_x_get(self: kotlin.native.internal.NativePtr): Double { val __self = kotlin.native.internal.ref.dereferenceExternalRCRef(self) as Vector val _result = __self.x return _result } @ExportedBridge("Vector_y_get") public fun Vector_y_get(self: kotlin.native.internal.NativePtr): Double { val __self = kotlin.native.internal.ref.dereferenceExternalRCRef(self) as Vector val _result = __self.y return _result } @ExportedBridge("Vector_plus__TypesOfArguments__SwiftExportDemo_Vector__") public fun Vector_plus__TypesOfArguments__SwiftExportDemo_Vector__(self: kotlin.native.internal.NativePtr, other: kotlin.native.internal.NativePtr): kotlin.native.internal.NativePtr { val __self = kotlin.native.internal.ref.dereferenceExternalRCRef(self) as Vector val __other = kotlin.native.internal.ref.dereferenceExternalRCRef(other) as Vector val _result = __self.plus(__other) return kotlin.native.internal.ref.createRetainedExternalRCRef(_result) } Kotlin Function Bridge (*.kt)

Slide 50

Slide 50 text

@ExportedBridge("Vector_x_get") public fun Vector_x_get(self: kotlin.native.internal.NativePtr): Double { val __self = kotlin.native.internal.ref.dereferenceExternalRCRef(self) as Vector val _result = __self.x return _result } @ExportedBridge("Vector_y_get") public fun Vector_y_get(self: kotlin.native.internal.NativePtr): Double { val __self = kotlin.native.internal.ref.dereferenceExternalRCRef(self) as Vector val _result = __self.y return _result } @ExportedBridge("Vector_plus__TypesOfArguments__SwiftExportDemo_Vector__") public fun Vector_plus__TypesOfArguments__SwiftExportDemo_Vector__(self: kotlin.native.internal.NativePtr, other: kotlin.native.internal.NativePtr): kotlin.native.internal.NativePtr { val __self = kotlin.native.internal.ref.dereferenceExternalRCRef(self) as Vector val __other = kotlin.native.internal.ref.dereferenceExternalRCRef(other) as Vector val _result = __self.plus(__other) return kotlin.native.internal.ref.createRetainedExternalRCRef(_result) } Kotlin Function Bridge (*.kt)

Slide 51

Slide 51 text

Kotlin Function Bridge (*.kt) @ExportedBridge("Vector_x_get") public fun Vector_x_get(self: kotlin.native.internal.NativePtr): Double { val __self = kotlin.native.internal.ref.dereferenceExternalRCRef(self) as Vector val _result = __self.x return _result } @ExportedBridge("Vector_y_get") public fun Vector_y_get(self: kotlin.native.internal.NativePtr): Double { val __self = kotlin.native.internal.ref.dereferenceExternalRCRef(self) as Vector val _result = __self.y return _result } @ExportedBridge("Vector_plus__TypesOfArguments__SwiftExportDemo_Vector__") public fun Vector_plus__TypesOfArguments__SwiftExportDemo_Vector__(self: kotlin.native.internal.NativePtr, other: kotlin.native.internal.NativePtr): kotlin.native.internal.NativePtr { val __self = kotlin.native.internal.ref.dereferenceExternalRCRef(self) as Vector val __other = kotlin.native.internal.ref.dereferenceExternalRCRef(other) as Vector val _result = __self.plus(__other) return kotlin.native.internal.ref.createRetainedExternalRCRef(_result) }

Slide 52

Slide 52 text

Kotlin Function Bridge (*.kt) @ExportedBridge("Vector_x_get") public fun Vector_x_get(self: kotlin.native.internal.NativePtr): Double { val __self = kotlin.native.internal.ref.dereferenceExternalRCRef(self) as Vector val _result = __self.x return _result } @ExportedBridge("Vector_y_get") public fun Vector_y_get(self: kotlin.native.internal.NativePtr): Double { val __self = kotlin.native.internal.ref.dereferenceExternalRCRef(self) as Vector val _result = __self.y return _result } @ExportedBridge("Vector_plus__TypesOfArguments__SwiftExportDemo_Vector__") public fun Vector_plus__TypesOfArguments__SwiftExportDemo_Vector__(self: kotlin.native.internal.NativePtr, other: kotlin.native.internal.NativePtr): kotlin.native.internal.NativePtr { val __self = kotlin.native.internal.ref.dereferenceExternalRCRef(self) as Vector val __other = kotlin.native.internal.ref.dereferenceExternalRCRef(other) as Vector val _result = __self.plus(__other) return kotlin.native.internal.ref.createRetainedExternalRCRef(_result) }

Slide 53

Slide 53 text

void * Vector_plus__TypesOfArguments__SwiftExportDemo_Vector__(void * self, void * other); double Vector_x_get(void * self); double Vector_y_get(void * self); C Header (*.h)

Slide 54

Slide 54 text

public final class Vector: KotlinRuntime.KotlinBase, KotlinRuntimeSupport._KotlinBridged { public var x: Swift.Double { get { return Vector_x_get(self.__externalRCRef()) } } public var y: Swift.Double { get { return Vector_y_get(self.__externalRCRef()) } } public static func +( this: SwiftExportDemo.Vector, other: SwiftExportDemo.Vector ) -> SwiftExportDemo.Vector { this._plus(other: other) } public func _plus( other: SwiftExportDemo.Vector ) -> SwiftExportDemo.Vector { return SwiftExportDemo.Vector.__createClassWrapper(externalRCRef: Vector_plus__TypesOfArguments__SwiftExportDemo_Vector__(self.__externalRCRef(), other.__externalRCRef())) } } Swift Wrapper (*.swift)

Slide 55

Slide 55 text

public final class Vector: KotlinRuntime.KotlinBase, KotlinRuntimeSupport._KotlinBridged { public var x: Swift.Double { get { return Vector_x_get(self.__externalRCRef()) } } public var y: Swift.Double { get { return Vector_y_get(self.__externalRCRef()) } } public static func +( this: SwiftExportDemo.Vector, other: SwiftExportDemo.Vector ) -> SwiftExportDemo.Vector { this._plus(other: other) } public func _plus( other: SwiftExportDemo.Vector ) -> SwiftExportDemo.Vector { return SwiftExportDemo.Vector.__createClassWrapper(externalRCRef: Vector_plus__TypesOfArguments__SwiftExportDemo_Vector__(self.__externalRCRef(), other.__externalRCRef())) } } Swift Wrapper (*.swift)

Slide 56

Slide 56 text

public final class Vector: KotlinRuntime.KotlinBase, KotlinRuntimeSupport._KotlinBridged { public var x: Swift.Double { get { return Vector_x_get(self.__externalRCRef()) } } public var y: Swift.Double { get { return Vector_y_get(self.__externalRCRef()) } } public static func +( this: SwiftExportDemo.Vector, other: SwiftExportDemo.Vector ) -> SwiftExportDemo.Vector { this._plus(other: other) } public func _plus( other: SwiftExportDemo.Vector ) -> SwiftExportDemo.Vector { return SwiftExportDemo.Vector.__createClassWrapper(externalRCRef: Vector_plus__TypesOfArguments__SwiftExportDemo_Vector__(self.__externalRCRef(), other.__externalRCRef())) } } Swift Wrapper (*.swift)

Slide 57

Slide 57 text

public final class Vector: KotlinRuntime.KotlinBase, KotlinRuntimeSupport._KotlinBridged { public var x: Swift.Double { get { return Vector_x_get(self.__externalRCRef()) } } public var y: Swift.Double { get { return Vector_y_get(self.__externalRCRef()) } } public static func +( this: SwiftExportDemo.Vector, other: SwiftExportDemo.Vector ) -> SwiftExportDemo.Vector { this._plus(other: other) } public func _plus( other: SwiftExportDemo.Vector ) -> SwiftExportDemo.Vector { return SwiftExportDemo.Vector.__createClassWrapper(externalRCRef: Vector_plus__TypesOfArguments__SwiftExportDemo_Vector__(self.__externalRCRef(), other.__externalRCRef())) } } Swift Wrapper (*.swift)

Slide 58

Slide 58 text

No content

Slide 59

Slide 59 text

KOTLIN KOTLIN Swift Wrapper C Header Kotlin Function Bridge

Slide 60

Slide 60 text

vector.x KOTLIN KOTLIN Swift Wrapper C Header Kotlin Function Bridge

Slide 61

Slide 61 text

vector.x KOTLIN KOTLIN Swift Wrapper C Header Kotlin Function Bridge double Vector_x_get(void * self);

Slide 62

Slide 62 text

fun Vector_x_get(self: kotlin.native.internal.NativePtr): Double vector.x KOTLIN KOTLIN Swift Wrapper C Header Kotlin Function Bridge double Vector_x_get(void * self);

Slide 63

Slide 63 text

Swift Export Pipeline 1. Analysis APIͰηϚϯςΟοΫΛղੳ 2. Swift IRͷੜ੒ 3. SirPrinter / BridgeGeneratorͰϒϦοδΛੜ੒͢Δ 4. Kotlin NativeίϯύΠϥ / SwiftίϯύΠϥͰϏϧυ

Slide 64

Slide 64 text

Swift Export Pipeline 1. Analysis APIͰηϚϯςΟοΫΛղੳ 2. Swift IRͷੜ੒ 3. SirPrinter / BridgeGeneratorͰϒϦοδΛੜ੒͢Δ 4. Kotlin NativeίϯύΠϥ / SwiftίϯύΠϥͰϏϧυ

Slide 65

Slide 65 text

KOTLIN

Slide 66

Slide 66 text

KOTLIN KOTLIN Kotlin Function Bridge Kotlin Native Library

Slide 67

Slide 67 text

KOTLIN KOTLIN Kotlin Function Bridge Kotlin Native Library C Header Swift Wrapper Swift Package

Slide 68

Slide 68 text

No content

Slide 69

Slide 69 text

Swift Package΁ͷग़ྗ • όΠφϦͰ͸ͳ͘SwiftͷιʔείʔυΛ௚઀ు͖ग़͠ɺSwift Packageͱͯ͠ import͢Δ͜ͱͰXcode͔Βར༻͠΍͘͢ͳΔ • ैདྷͷApple Framework΁ͷܗࣜΑΓऔΓճ͠΍͍͢ • ύοέʔδͷϏϧυ͸SwiftͷϏϧυγεςϜʹ೚ͤΔ • Kotlin NativeίϯύΠϥ͸Kotlin࣮૷ͷϥΠϒϥϦԽͱϒϦοδͷΈΛϏϧυ

Slide 70

Slide 70 text

ϩʔυϚοϓ • ObjC Exportͷػೳʹ·ͩ௥͍͍͍ͭͯͳ͍ • ݱஈ֊Ͱ͸Swift Exportಛ༗ͷػೳ΄ͱΜͲͳ͍ • ·ͣObjC ExportͱͷػೳࠩҟΛݮΒ͍ͯ͘͜͠ͱΛ໨ࢦ͍ͯ͠Δ • Swift Exportݻ༗ͷػೳ͕௥Ճ͞Ε͍ͯ͘ͷ͸͜Ε͔Β • ݱࡏར༻Մೳͳݴޠػೳ͸ҎԼʹ·ͱ·͍ͬͯΔ • https://kotl.in/swift-export-feature-status

Slide 71

Slide 71 text

https://kotl.in/swift-export-feature-status

Slide 72

Slide 72 text

• https://youtrack.jetbrains.com/issue/KT-64572/The- fi rst-public-release-of-Swift-Export

Slide 73

Slide 73 text

• https://youtrack.jetbrains.com/issue/KT-64572/The- fi rst-public-release-of-Swift-Export

Slide 74

Slide 74 text

Objective-C Export Swift Export ग़ྗํ޲ ૒ํ޲ Kotlin -> SwiftͷΈ தؒදݱͷੜ੒ LLVM IRΛ௚઀ੜ੒ K2ͷAnalytics API͔Βઐ༻ͷIRΛ࡞੒ ग़ྗܗࣜ όΠφϦ + ObjCϔομ όΠφϦ + Swiftίʔυ Ϗϧυํ๏ Kotlin Native CompilerͰFrameworkԽ Kotlin Native Compiler + SwiftϏϧυγε ςϜ Gradle Taskͷݺͼग़͠ ୯ମͰ࣮ߦՄೳ XcodeͷBuild Phase͔ΒͷΈ࣮ߦՄೳ ࠷ऴ੒Ռ෺ Apple Framework (*.framework) Swift Package

Slide 75

Slide 75 text

·ͱΊ • SwiftίʔυΛੜ੒͢ΔΑ͏ʹͳΓදݱྗ্͕͕ͬͨ • Kotlin NativeͷόΠφϦΛ࣮ߦ͢ΔͨΊͷCϒϦοδΛSwiftͰϥοϓ͢Δ • K2 CompilerͷAnalysis APIΛ࢖ͬͨඪ४తͳ࢓૊ΈͰૄ݁߹ʹͳͬͨɻϏϧ υͱϒϦοδͷੜ੒͕੾Γ཭͞Εͨ • Ұ෦ػೳ͸·ͩະ࣮૷ • Xcode্͔Β͔࣮͠ߦͰ͖ͳ͍ • ObjC ExportͰ࣮ݱͰ͖ΔػೳͷҰ෦͕ະ࣮૷ͳͲ

Slide 76

Slide 76 text

Thank you!

Slide 77

Slide 77 text

References • Swift Export - a peek under the hood - Kotlin Conf 2025 • https://2025.kotlinconf.com/talks/798313/ • Swift Export: Natural Interoperability between Kotlin and Swift | by Santiago Mattiauda | Medium • https://medium.com/@santimattius/swift-export-natural-interoperability- between-kotlin-and-swift-720799961edc • kotlin/docs/swift-export/architecture.md at master · JetBrains/kotlin • https://github.com/JetBrains/kotlin/blob/master/docs/swift-export/ architecture.md

Slide 78

Slide 78 text

References • Exploring Kotlin (native) compilation | by Filip Wiesner | MateeDevs | Medium • https://medium.com/mateedevs/exploring-kotlin-native- compilation-7d396b0b7fde • How Kotlin Swift Export Works - YouTube • https://www.youtube.com/watch?v=qtWHRrIfKbQ • Swift Export͸Ͳ͔͜Βདྷͨͷ͔ɺSwift Export͸Կऀ͔ɺSwift Export͸Ͳ͜ ΁ߦ͘ͷ͔ • https://zenn.dev/f0x/articles/f0d2d1320794bd