Gradle plugin that syncs Trikot's iOS Swift extensions into consumer projects. This replaces CocoaPods subspecs for distributing Swift extensions, enabling SPM-based projects to use Trikot without CocoaPods.
Each Trikot module can ship Swift extensions in a swift-extensions/ directory (e.g. trikot-viewmodels/swift-extensions/). The plugin packages all of these into its JAR at build time, auto-discovering modules and files from the filesystem — no manual manifest is needed.
At sync time, the plugin:
- Copies the requested Swift files into the consumer's output directory
- Replaces
import TRIKOT_FRAMEWORK_NAMEwith the consumer's configured framework name - Removes
import Trikotlines (no longer needed outside CocoaPods)
Consumer apps are responsible for having the required third-party dependencies (e.g. Kingfisher, Reachability) available in their project for whichever modules they use.
Add the plugin to your project's build.gradle.kts:
plugins {
id("com.mirego.trikot.swift-extensions") version "$trikot_version"
}trikotSwiftExtensions {
frameworkName.set("Shared") // Required — your KMP framework name
outputDir.set(file("ios/TrikotExtensions")) // Required — where Swift files are written
modules.set(listOf( // Optional — defaults to all available modules
"streams",
"viewmodels",
"viewmodels-kingfisher",
"http",
"kword",
))
}| Property | Type | Default | Description |
|---|---|---|---|
frameworkName |
String |
— | The KMP framework name used in import statements. |
outputDir |
Directory |
— | Directory where Swift extension files are written. |
modules |
List<String> |
all available | Trikot modules to sync. Empty list syncs everything. |
Run the sync task:
./gradlew syncTrikotSwiftExtensionsThis will populate the output directory with one subdirectory per module. Sub-modules preserve any internal directory structure they declare on disk:
ios/TrikotExtensions/
http/
TrikotConnectivityService.swift
TrikotHttpRequest.swift
...
viewmodels/
UIButtonExtensions.swift
UIViewExtensions.swift
...
viewmodels-kingfisher/
KFImageViewModelHandler.swift
viewmodels-declarative-flow-swiftui/
TrikotViewModelDeclarative.swift
Components/
VMDButton.swift
Snackbar/
VMDSnackbar.swift
Extensions/
VMDAnimation+Extensions.swift
...
Modules are auto-discovered from trikot-*/swift-extensions/ directories. Currently available:
| Module | Dependencies | Description |
|---|---|---|
streams |
— | Publisher extensions |
streams-combine |
— | Combine framework interop |
viewmodels |
— | UIKit view model bindings |
viewmodels-kingfisher |
Kingfisher | Image loading with Kingfisher |
viewmodels-declarative-core |
— | Declarative view model core extensions |
viewmodels-declarative-combine |
— | Combine framework interop for declarative view models |
viewmodels-declarative-uikit |
Kingfisher | UIKit bindings for declarative view models |
viewmodels-declarative-swiftui |
Kingfisher | SwiftUI bindings for declarative view models |
viewmodels-declarative-flow |
— | Declarative view model flow extensions |
viewmodels-declarative-flow-swiftui |
Kingfisher | SwiftUI bindings for declarative flow |
http |
Reachability | HTTP client and connectivity |
kword |
— | i18n string extensions |
bluetooth |
— | CoreBluetooth extensions |
analytics-firebase |
FirebaseAnalytics | Firebase analytics service |
analytics-mixpanel |
Mixpanel | Mixpanel analytics service |
To add Swift extensions to an existing or new Trikot module, place .swift files in a swift-extensions/ directory under the module:
trikot-mymodule/
swift-extensions/
MyExtension.swift
Sub-modules are supported via subdirectories one level deep. Each first-level subdirectory of swift-extensions/ becomes its own module key:
trikot-mymodule/
swift-extensions/
MyExtension.swift # module key: "mymodule"
subfeature/
SubExtension.swift # module key: "mymodule-subfeature"
The root module is flat — only .swift files placed directly under swift-extensions/ are included. Sub-modules may organize their files into nested subdirectories for readability; the structure is preserved end-to-end into the consumer's output directory:
trikot-mymodule/
swift-extensions/
subfeature/
SubExtension.swift # → outputDir/mymodule-subfeature/SubExtension.swift
Components/
ComponentA.swift # → outputDir/mymodule-subfeature/Components/ComponentA.swift
Detail/
Helper.swift # → outputDir/mymodule-subfeature/Components/Detail/Helper.swift
Note: deeper nested directories are organization within a sub-module, not new module keys. Only the first level under swift-extensions/ is promoted to a module.
Use import TRIKOT_FRAMEWORK_NAME in your Swift files — it will be replaced with the consumer's framework name at sync time.