Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Whats the right way to use swiftklib? #54

Open
Kashif-E opened this issue Jan 14, 2025 · 0 comments
Open

Whats the right way to use swiftklib? #54

Kashif-E opened this issue Jan 14, 2025 · 0 comments

Comments

@Kashif-E
Copy link

Kashif-E commented Jan 14, 2025

this is how i am trying to do it

import io.github.ttypic.swiftklib.gradle.api.ExperimentalSwiftklibApi

plugins {
    alias(libs.plugins.multiplatform)
    alias(libs.plugins.android.library)
    alias(libs.plugins.kotlinx.serialization)
    id("convention.publication")
    alias(libs.plugins.compose.compiler)
    alias(libs.plugins.compose)
    alias(libs.plugins.swiftKlib)
}

group = "com.mia.stripe"
version = "1.0.0"

kotlin {

    jvmToolchain(17)

    androidTarget { publishLibraryVariants("release") }
    listOf(
        iosX64(),
        iosArm64(),
        iosSimulatorArm64()
    ).forEach { iosTarget ->
        iosTarget.compilations {
            val main by getting {
                cinterops {
                    create("MiaStripe")
                }
            }

        }
    }
    sourceSets {
        val commonMain by getting {
            dependencies {
                implementation(libs.kotlinx.coroutines.core)
                implementation(compose.foundation)
                implementation(compose.runtime)
            }
        }
        val commonTest by getting {
            dependencies {
                implementation(kotlin("test"))
            }
        }
        val androidMain by getting {
            dependencies {
                implementation(libs.kotlinx.coroutines.android)
                implementation("com.stripe:stripe-android:20.41.0")
                implementation("com.stripe:stripe-java:25.3.0")
                implementation(libs.androidx.activityCompose)
            }
        }
        val androidUnitTest by getting
        val iosX64Main by getting
        val iosArm64Main by getting
        val iosSimulatorArm64Main by getting
        val iosMain by creating {
            dependsOn(commonMain)
            iosX64Main.dependsOn(this)
            iosArm64Main.dependsOn(this)
            iosSimulatorArm64Main.dependsOn(this)
        }
        val iosX64Test by getting
        val iosArm64Test by getting
        val iosSimulatorArm64Test by getting
        val iosTest by creating {
            dependsOn(commonTest)
            iosX64Test.dependsOn(this)
            iosArm64Test.dependsOn(this)
            iosSimulatorArm64Test.dependsOn(this)
        }
    }


    //https://kotlinlang.org/docs/native-objc-interop.html#export-of-kdoc-comments-to-generated-objective-c-headers
    targets.withType<org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget> {
        compilations["main"].compileTaskProvider.configure {
            compilerOptions {
                freeCompilerArgs.add("-Xexport-kdoc")
            }
        }
    }

}

android {
    namespace = "com.mia.stripe"
    compileSdk = 35

    defaultConfig {
        minSdk = 21
    }
}


swiftklib {
    create("MiaStripe") {
        path = file("src/iosMain/swift/mia")
        packageName("com.mia.stripe.ios")
        minIos = "14.0"
        @OptIn(ExperimentalSwiftklibApi::class)
        dependencies {
            remote(listOf("StripeCore", "StripePaymentSheet")) {
                url("https://github.com/stripe/stripe-ios.git", "stripe-ios")
                exactVersion("24.3.0")
            }
        }

    }

}
//kotlin.targets.withType<org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget> {
//    compilations["main"].cinterops {
//        create("StripeIoxs") {
//            // defFile(project.file("src/nativeInterop/cinterop/stripeIos.def"))
//            packageName("com.stripe.ios")
//            compilerOpts("-framework", "Stripe")
//            // includeDirs.allHeaders("path/to/stripe/headers")  // If needed
//        }
//    }
//}

Task :stripeSdk:swiftklibMiaStripeIosSimulatorArm64
Fetching https://github.com/stripe/stripe-ios.git from cache
Fetched https://github.com/stripe/stripe-ios.git from cache (1.55s)
Computing version for https://github.com/stripe/stripe-ios.git
Computed https://github.com/stripe/stripe-ios.git at 24.3.0 (0.02s)
Creating working copy for https://github.com/stripe/stripe-ios.git
Working copy of https://github.com/stripe/stripe-ios.git resolved at 24.3.0
warning: 'swiftbuild': dependency 'stripe-ios' is not used by any target
'swiftbuild': dependency 'stripe-ios' is not used by any target

inside file mia
i have this code

import StoreKit
import UIKit
import StripeCore

and here StripeCore is undefined

@Kashif-E Kashif-E changed the title Whats the right way to right siwft package with swiftklib? Whats the right way to use swiftklib? Jan 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant