Skip to content
This repository was archived by the owner on Sep 8, 2025. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,41 @@ dependencies {

# Usage

## Xcode configuration

The Swift code generated from this plugin is not automatically included in the shared framework you might have.

You have 2 options to use it in your iOS project:
- Xcode direct file integration
- CocoaPods integration

### Xcode direct file integration

You can directly import the generated file in your Xcode project like it's a file you have written on your own.

To do so:
- open the Xcode project
- right click on "iosApp"
- choose "Add files to iOSApp"
- add the file from the generated folder (you might need to read the FAQ to know where the generated folder is)
- you are now good to go!

### CocoaPods integration

After you have added the moko-kswift plugin to your shared module and synced your project, a new Gradle task should appear with name `kSwiftXXXXXPodspec` where `XXXXX` is the name of your shared module (so your task might be named `kSwiftsharedPodspec`).

- Run the task doing `./gradlew kSwiftsharedPodspec` from the root of your project.
This will generate a new podspec file, `XXXXXSwift.podspec`, where `XXXXX` is still the name of your shared module (so e.g. `sharedSwift.podspec`)

- Now edit the `Podfile` inside the iOS project adding this line
`pod 'sharedSwift', :path => '../shared'`
just after the one already there for the already available shared module
`pod 'shared', :path => '../shared'`

- Now run `pod install` from the `iosApp` folder so the new framework is linked to your project.

- Whenever you need a Swift file generated from moko-kswift just import the generated module (e.g. `import sharedSwift`) and you are good to go!

## Sealed classes/interfaces to Swift enum

Enable feature in project `build.gradle`:
Expand Down Expand Up @@ -422,6 +457,11 @@ kswift {
}
```

# Samples

- [branch regular-framework](https://github.com/Alex009/moko-kswift-usage-sample/tree/regular-framework) - how to use KSwift without cocoapods
- [branch cocoapods](https://github.com/Alex009/moko-kswift-usage-sample/tree/cocoapods) - how to use KSwift with JetBrains CocoaPods plugin

# FAQ

## Where destination directory for all generated sources?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ internal class PostProcessLinkTask(
outputDir.deleteRecursively()

linkTask.inputs.files
.filter { it.extension == "klib" }
.filter { file ->
val name = file.nameWithoutExtension
if (kSwiftExtension.includedLibs.isNotEmpty()) {
Expand Down
Loading