Closed Soabbar closed 1 month ago
@Soabbar you missed import ComposeApp
in ios part instead of import shared
. This name comes from baseName that is defined in gradle file:
iosTarget.binaries.framework {
export("io.github.mirzemehdi:kmpnotifier:1.2.1")
baseName = "ComposeApp" <--- this one
isStatic = true
}
Hi @mirzemehdi i am facing the above same issue can you please guide what is wrong as it is working fine on android side but kmpnotifier files are not importing in ios side
cocoapods { ios.deploymentTarget = "14.1" version = "1.0.0" summary = "Shared module of CmpDemo Trucker" homepage = "https://github.com/mubarakaali/CMPDemoWithCleanArchitecure/" framework { baseName = "ComposeApp" isStatic = true binaryOption("bundleId", "com.truckitin.trucker.composeApp") export(libs.kmpNotifier) } }
w: Interop library /Users/user/.gradle/caches/modules-2/files-2.1/io.github.mirzemehdi/kmpnotifier-iossimulatorarm64/1.2.1/27a61887b5ed9a8ca27ff4e4dd1738d85bad22f8/kmpnotifier-cinterop-FirebaseMessaging can't be exported with -Xexport-library
Receiving the same error but only during Archive in XCode:
/.gradle/caches/modules-2/files-2.1/io.github.mirzemehdi/kmpnotifier-iosarm64/1.2.1/c5fcf18c756435afc89eba49421b9ee1d3468865/kmpnotifier-cinterop-FirebaseMessaging can't be exported with -Xexport-library
Note: No problem running iOS app on either Android Studio or XCode.
@mubarakaali
ios setup should be like this:
https://github.com/mirzemehdi/KMPNotifier?tab=readme-ov-file#ios-setup
import SwiftUI
import shared
import FirebaseCore
import FirebaseMessaging
class AppDelegate: NSObject, UIApplicationDelegate {
func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
FirebaseApp.configure() //important
//By default showPushNotification value is true.
//When set showPushNotification to false foreground push notification will not be shown.
//You can still get notification content using #onPushNotification listener method.
NotifierManager.shared.initialize(configuration: NotificationPlatformConfigurationIos(
showPushNotification: true,
askNotificationPermissionOnStart: true)
)
return true
}
func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
Messaging.messaging().apnsToken = deviceToken
}
}
@main
struct iOSApp: App {
@UIApplicationDelegateAdaptor(AppDelegate.self) var delegate
var body: some Scene {
WindowGroup {
ContentView()
}
}
}
@andiosdev can you please share more info from your xcode/ios configuration. Can't reproduce it. Maybe just try invalidate cache and restart.
@mirzemehdi this is what my Build iosApp - Log
@andiosdev error is related to heap space. in gradle properties search for jvmargs and set heap space value 4GB as below:
org.gradle.jvmargs=-Xmx4G
kotlin.daemon.jvmargs=-Xmx4G
org.gradle.jvmargs=-Xmx4G kotlin.daemon.jvmargs=-Xmx4G
Thank you @mirzemehdi . This fixes the issue.
@Soabbar you missed
import ComposeApp
in ios part instead ofimport shared
. This name comes from baseName that is defined in gradle file:iosTarget.binaries.framework { export("io.github.mirzemehdi:kmpnotifier:1.2.1") baseName = "ComposeApp" <--- this one isStatic = true }
@mirzemehdi Perhaps setup guide should be updated to clarify this? I am not a iOS dev, and I wasted a few hours trying to solve this.
@Vkalns It is actually common Kotlin Multiplatform knowledge already. But will add some note as well then since it can cause some confusion. Thanks for mentioning
Hi @mirzemehdi KMPNotifier and Kotlin version: kmpnotifier version: 1.2.1, kotlin version: 2.0.0
Describe the bug Setting up the library in Android seems to be working fine but it is not on iOS.
In which platform bug occurs? ios
To Reproduce I followed the README but I am a bit confused about the
Import shared
I am using the Compose Multiplatform from Jetbrains, is that compatible?