{"id":13537463,"url":"https://github.com/ttypic/swift-klib-plugin","last_synced_at":"2025-04-12T16:41:08.744Z","repository":{"id":65786474,"uuid":"425447153","full_name":"ttypic/swift-klib-plugin","owner":"ttypic","description":"Gradle Plugin for injecting Swift code into Kotlin Multiplatform Mobile shared module","archived":false,"fork":false,"pushed_at":"2024-11-27T18:37:03.000Z","size":289,"stargazers_count":266,"open_issues_count":13,"forks_count":15,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-04-03T19:13:06.876Z","etag":null,"topics":["gradle","gradle-plugin","ios","kotlin","kotlin-multiplatform","kotlin-multiplatform-mobile","kotlin-native","swift","swift-kotlin"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ttypic.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-11-07T09:10:14.000Z","updated_at":"2025-04-03T14:37:52.000Z","dependencies_parsed_at":"2023-11-15T23:27:14.380Z","dependency_job_id":"32961bff-ac32-4001-9806-9048597fe822","html_url":"https://github.com/ttypic/swift-klib-plugin","commit_stats":{"total_commits":84,"total_committers":8,"mean_commits":10.5,"dds":"0.44047619047619047","last_synced_commit":"7df04f074c53a4768452f5a93ba8265ccf00860b"},"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ttypic%2Fswift-klib-plugin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ttypic%2Fswift-klib-plugin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ttypic%2Fswift-klib-plugin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ttypic%2Fswift-klib-plugin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ttypic","download_url":"https://codeload.github.com/ttypic/swift-klib-plugin/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248598628,"owners_count":21131125,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["gradle","gradle-plugin","ios","kotlin","kotlin-multiplatform","kotlin-multiplatform-mobile","kotlin-native","swift","swift-kotlin"],"created_at":"2024-08-01T09:00:59.323Z","updated_at":"2025-04-12T16:41:08.710Z","avatar_url":"https://github.com/ttypic.png","language":"Kotlin","funding_links":[],"categories":["Libraries"],"sub_categories":["Build \u0026 Development Tools"],"readme":"\u003cimg src=\"https://github.com/ttypic/swift-klib-plugin/raw/main/docs/media/swiftklib-light.svg\" alt=\"Swift Klib library logo\" width=\"300\"\u003e\n\n# Swift Klib Gradle Plugin\n\n![badge-ios](https://img.shields.io/badge/platform-ios-light)\n![badge-mac](https://img.shields.io/badge/platform-macos-light)\n![badge-tvos](https://img.shields.io/badge/platform-tvos-light)\n![badge-watchos](https://img.shields.io/badge/platform-watchos-light)\n\nThis gradle plugin provides easy way to include your Swift source files in your **Kotlin Multiplatform Mobile**\nshared module and access them in Kotlin via `cinterop` for iOS targets. It is useful for:\n\n* Accessing Swift-only libraries _(e.g. CryptoKit)_\n* Creating a Kotlin-Friendly Swift API\n* Learning how Swift \u003c-\u003e Kotlin interoperability works\n\n**Note:** _Plugin has been tested on Gradle 7.5+, Xcode 15+_\n\n## Installation\n\nUsing the [plugins DSL](https://docs.gradle.org/current/userguide/plugins.html#sec:plugins_block):\n\n```kotlin\nplugins {\n    id(\"io.github.ttypic.swiftklib\") version \"0.6.4\"\n}\n```\n\nUsing [legacy plugin application](https://docs.gradle.org/current/userguide/plugins.html#sec:old_plugin_application):\n\n```kotlin\nbuildscript {\n  repositories {\n    maven {\n      url = uri(\"https://plugins.gradle.org/m2/\")\n    }\n  }\n  dependencies {\n    classpath(\"io.github.ttypic:plugin:0.6.4\")\n  }\n}\n\napply(plugin = \"io.github.ttypic.swiftklib\")\n```\nAdd this to the project-level gradle.properties file (if it’s not already included).\n```properties\n#Kotlin Multiplatform\nkotlin.mpp.enableCInteropCommonization=true\n\n```\n\n## Usage\n\nPlugin works together with [Kotlin Multiplatform plugin](https://plugins.gradle.org/plugin/org.jetbrains.kotlin.multiplatform).\n\n### Prepare Swift code\n\nPlace your Swift files inside your project in separate folder (e.g. `native/HelloSwift`).\n\nMake sure that Swift API you want to expose to Kotlin is [compatible with Objective-C](https://lazarevzubov.medium.com/compatible-with-objective-c-swift-code-e7c3239d949).\n\n```swift\n@objc public class HelloWorld : NSObject {\n    @objc public class func helloWorld() -\u003e String {\n        return \"HeLLo WorLd!\"\n    }\n}\n```\n\n### Setup swiftklib extension\n\nThen you need to add `cinterop` for target platforms in your **Kotlin Multiplatform Plugin**. There is\nno need to configure it or add `.def` file, all configuration will be done automatically by **Swift Klib**.\n\n```kotlin\nkotlin {\n    listOf(\n        iosX64(),\n        iosArm64(),\n        iosSimulatorArm64(),\n    ).forEach {\n        it.compilations {\n            val main by getting {\n                cinterops {\n                    create(\"HelloSwift\")\n                }\n            }\n        }\n    }\n\n    //...\n}\n```\n\nAnd finally provide settings for it in `swiftklib` extension.\nYou need to specify `path` and `packageName` parameters.\n\n```kotlin\nswiftklib {\n    create(\"HelloSwift\") {\n        path = file(\"native/HelloSwift\")\n        packageName(\"com.ttypic.objclibs.greeting\")\n    }\n}\n```\n\n### Examples\n\n- More samples can be found in the [examples/](https://github.com/ttypic/swift-klib-plugin/tree/main/examples) folder.\n- Component demonstrating a multipurpose Kotlin Multiplatform and Swift Package audio player: [radioplayer-kt](https://github.com/markst/radioplayer-kt)\n\n## License\n\nThis package is licensed under MIT license.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fttypic%2Fswift-klib-plugin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fttypic%2Fswift-klib-plugin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fttypic%2Fswift-klib-plugin/lists"}