Skip to content

Shared Rust code, to be used from Rust, Swift or Kotlin. Similar to Swisstronik.js

License

Notifications You must be signed in to change notification settings

SigmaGmbH/swisstronik-rust-swift-kotlin

Repository files navigation

Rust core for Kotlin and Swift Swisstronik libraries

This is the repo for shared Rust code to be used in Swisstronik Swift & Kotlin.

Usage:

Swift using swift build

Add it to your dependencies in Package.swift:

dependencies: [
    .package(url: "https://github.com/SigmaGmbH/swisstronik-rust-swift-kotlin", from: "1.0.0"),
],

Then add the library to target's dependencies:

.product(name: "SwisstronikSwift", package: "SwisstronikSwift"),

or, add it using XCode:

Swift using Xcode

If you are using Xcode, then you should:

  • Add this SwiftPM package https://github.com/SigmaGmbH/swisstronik-rust-swift-kotlin as dependency of your xcode project: Apple Docs

Kotlin

The package is hosted on Github Packages. In order to use it, you need to authenticate on Github using your token.

Here's a guide to working with Github Packages:

https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-gradle-registry

Here's the short version:

  1. Add to your Gradle dependencies:
dependencies {
    implementation "com.swisstronik.kotlin:1.0.0"
}
  1. Add the repository to your main build.gradle in repositories section:
repositories {
    maven {
        url = uri("https://maven.pkg.github.com/SigmaGmbH/swisstronik-rust-swift-kotlin")
        credentials {
            username = project.findProperty("gpr.user") ?: System.getenv("USERNAME")
            password = project.findProperty("gpr.key") ?: System.getenv("TOKEN")
        }
   }

Also, you can check out TrustWallet guide for detailed explanation. Don't forget to replace the link with https://maven.pkg.github.com/SigmaGmbH/swisstronik-rust-swift-kotlin !

Dependencies

Commands

Command runner - https://github.com/casey/just

Generate C header file for Swift:

just bindings

Generate Kotlin protobuf files:

just kotlinpb

Generate Swift protobuf files:

just swiftpb