mirzemehdi / KMPNotifier

Kotlin Multiplatform Push Notification Library targetting android, iOS, Desktop and Web (JS and Wasm)
http://mirzemehdi.com/KMPNotifier/
Apache License 2.0
340 stars 19 forks source link

Can't access the initializer in Swift. #8

Closed philippschadt closed 9 months ago

philippschadt commented 9 months ago

Hi,

I'm in a KMP Project (without Compose Multiplatform). My Repository(https://github.com/philippschadt/KMPNotifierApp).

I can't access the Initializer in my Swift code. I always get the error: Cannot find 'NotifierManager' in scope Cannot find 'NotificationPlatformConfigurationIos' in scope

I don't get what I'm doing wrong. Android is working well.

// iOSApp.swift

import SwiftUI
import shared

class AppDelegate: NSObject, UIApplicationDelegate {

    func application(
        _ application: UIApplication,
        didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {

       //  NotifierManager.shared.initialize(configuration: NotificationPlatformConfigurationIos.shared) // Not working

        return true
    }
}

@main
struct iOSApp: App {
    @UIApplicationDelegateAdaptor(AppDelegate.self) var delegate

    var body: some Scene {
        WindowGroup {
            ContentView()
        }
    }
}
//build.gradle.kts(:shared)

    listOf(
        iosX64(),
        iosArm64(),
        iosSimulatorArm64()
    ).forEach {
        it.binaries.framework {
            baseName = "shared"
            export(libs.kmpnotifier) // Does not solve it
            isStatic = true
        }
    }

sourceSets {
        commonMain.dependencies {
            api(libs.kmpnotifier)
        }
        commonTest.dependencies {
            implementation(libs.kotlin.test)
        }
        iosMain.dependencies {
            api(libs.kmpnotifier)
        }
    }
philippschadt commented 9 months ago

Obviously, it doesn't work if I select the simulator in Xcode. It works fine on a physical device or when I select My Mac as run destination.