KMPNotifier icon indicating copy to clipboard operation
KMPNotifier copied to clipboard

Cannot find 'NotifierManager' in scope

Open bpappin opened this issue 9 months ago • 7 comments

KMPNotifier and Kotlin version: kmpnotifier version: 1.5.1, kotlin version: 2.1.10

Describe the bug After following the instructions, i get the error: iOSApp.swift:34:9 Cannot find 'NotifierManager' in scope

In which platform bug occurs? ios

To Reproduce Just hit the build

Expected behavior Based on the instructions, it should just work. I would prefer to have it set up as a normal dependency, that would be easier to maintain.

Additional info to help reproduce If possible logs, or even a small sample project to help reproduce your case.

bpappin avatar Apr 12 '25 02:04 bpappin

Hi @mirzemehdi.

I've the same problem. I did everything based on the instruction, and I've no ideas what's wrong. Here is my iosApp file:

` import UIKit import ComposeApp import GoogleSignIn import FirebaseCore import FirebaseMessaging

@main class AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow?

func application(
    _ application: UIApplication,
    didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
    LetsGoAppKt.doInitMapKit()
    FirebaseApp.configure()
    
    NotifierManager.shared.initialize(configuration: NotificationPlatformConfigurationIos(
                showPushNotification: true,
                askNotificationPermissionOnStart: true,
                notificationSoundName: nil
              )
          )
    
    window = UIWindow(frame: UIScreen.main.bounds)
    if let window = window {
        window.rootViewController = MainKt.MainViewController()
        window.makeKeyAndVisible()
    }

    return true
}

func application(
    _ app: UIApplication,
    open url: URL,
    options: [UIApplication.OpenURLOptionsKey: Any] = [:]
) -> Bool {
    return GIDSignIn.sharedInstance.handle(url)
}

} `

and here are fragments from my build.gradle.kts file:

listOf( iosX64(), iosArm64(), iosSimulatorArm64() ).forEach { it.binaries.framework { export(libs.kmpNotifier) baseName = "ComposeApp" isStatic = true } }

commonMain.dependencies { ... other dependencies ... api(libs.kmpNotifier) }

I read other closed issues but they have no solutions for me. I also have no problems with java heap space. If I forgot any obvious things maybe it makes a sense to add it to the instruction? Maybe should I instal some packages from the xcode package manager?

shprotx avatar Apr 28 '25 08:04 shprotx

If anyone is having this issue, I ended up resolving it but I'm not sure what steps fixed it exactly. I was trying to get the iOS app to build and run in Android Studio and happened to get this error fixed as well. The two steps I think that could have helped are:

  1. downgrading Xcode to 16.0, since I was getting a warning that this was the latest version tested with Android Studio

  2. Ensuring the Xcode project file was pointed at the xcworkspace instead of the xcodeproj file.

Image

camka14 avatar May 16 '25 14:05 camka14

Got the same issue, not sure what's going on. As a workaround I have executed that code from the commonMain.

stevdza-san avatar Aug 03 '25 14:08 stevdza-san

Any updates?

mobidroid92 avatar Sep 03 '25 15:09 mobidroid92

Got the same issue, not sure what's going on. As a workaround I have executed that code from the commonMain.

Its worked for me too. Other solution that worked for me: when I changed my dependencies from cocoapods to the SPM, the NotifierManager become accessible in iOSApp.

rgielow avatar Sep 07 '25 14:09 rgielow

Technically, if in your gradle you export the library, it should be accesible from ios side. I am not sure what would be wrong. If you can provide minimum reproducible project githublink. I could loot at it

mirzemehdi avatar Sep 07 '25 15:09 mirzemehdi

I am getting same error

Compile iOSApp.swift (arm64) (15, 9) Cannot find 'NotifierManager' in scope (15, 58) Cannot find 'NotificationPlatformConfigurationIos' in scope (18, 36) 'nil' requires a contextual type

HunterPillu avatar Oct 01 '25 16:10 HunterPillu