mirzemehdi / KMPNotifier

Kotlin Multiplatform Push Notification Library targetting android and iOS
http://mirzemehdi.com/KMPNotifier/
Apache License 2.0
172 stars 10 forks source link

iOS compilation not working because FirebaseMessaging missing #14

Closed Sabriel1984 closed 3 months ago

Sabriel1984 commented 4 months ago

I followed instruction from here: https://proandroiddev.com/how-to-implement-push-notification-in-kotlin-multiplatform-5006ff20f76c on fresh Kotlin Multiplatform Project generated from Android Studio (without Cocoa Pods). Android works perfectly, but I still fighting with iOS compilation using 3 different IDE's (AS, Xcode and Fleet) and have no idea what is wrong. I paste build logs:

Task :shared:checkKotlinGradlePluginConfigurationErrors Task :shared:compileKotlinIosSimulatorArm64 FROM-CACHE Task :xcodeVersion Task :shared:linkDebugFrameworkIosSimulatorArm64 Interop library /Users/krajchel/.gradle/caches/modules-2/files-2.1/io.github.mirzemehdi/kmpnotifier-iossimulatorarm64/0.3.0/2560dce3e2f5075adb55c667bf5773ac5d308281/kmpnotifier-cinterop-FirebaseMessaging can't be exported with -Xexport-librarywarning: Interop library /Users/krajchel/.gradle/caches/modules-2/files-2.1/io.github.mirzemehdi/kmpnotifier-iossimulatorarm64/0.3.0/2560dce3e2f5075adb55c667bf5773ac5d308281/kmpnotifier-cinterop-FirebaseMessaging can't be exported with -Xexport-library

....

User defaults from command line: IDECustomDerivedDataLocation = /Users/krajchel/Library/Caches/JetBrains/Fleet/backend/KMPNotifierTest.ep2jv5j26q040f498ad9/DerivedData IDEPackageSupportUseBuiltinSCM = YES

Build settings from command line: COCOAPODS_SKIP_KOTLIN_BUILD = YES OBJROOT = /Users/krajchel/Library/Caches/JetBrains/Fleet/backend/KMPNotifierTest.ep2jv5j26q040f498ad9/DerivedData/iosApp-ddgrzpipzoxfiieeifejojlabfys/Build/Intermediates.noindex OVERRIDE_KOTLIN_BUILD_IDE_SUPPORTED = YES SYMROOT = /Users/krajchel/Library/Caches/JetBrains/Fleet/backend/KMPNotifierTest.ep2jv5j26q040f498ad9/DerivedData/iosApp-ddgrzpipzoxfiieeifejojlabfys/Build/Products TEST_AFTER_BUILD = NO

--- xcodebuild: WARNING: Using the first of multiple matching destinations: { platform:iOS Simulator, id:B511D847-FB0A-410C-8B2C-231EFEA17861, OS:17.2, name:iPhone 15 } { platform:iOS Simulator, id:B511D847-FB0A-410C-8B2C-231EFEA17861, OS:17.2, name:iPhone 15 } Prepare packages

...

Ld /Users/krajchel/Library/Caches/JetBrains/Fleet/backend/KMPNotifierTest.ep2jv5j26q040f498ad9/DerivedData/iosApp-ddgrzpipzoxfiieeifejojlabfys/Build/Products/Debug-iphonesimulator/iosApp.app/iosApp normal (in target 'iosApp' from project 'iosApp') cd /Users/krajchel/Development/AndroidStudio/KMPNotifierTest/iosApp /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -Xlinker -reproducible -target arm64-apple-ios16.0-simulator -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator17.2.sdk -O0 -L/Users/krajchel/Library/Caches/JetBrains/Fleet/backend/KMPNotifierTest.ep2jv5j26q040f498ad9/DerivedData/iosApp-ddgrzpipzoxfiieeifejojlabfys/Build/Intermediates.noindex/EagerLinkingTBDs/Debug-iphonesimulator -L/Users/krajchel/Library/Caches/JetBrains/Fleet/backend/KMPNotifierTest.ep2jv5j26q040f498ad9/DerivedData/iosApp-ddgrzpipzoxfiieeifejojlabfys/Build/Products/Debug-iphonesimulator -F/Users/krajchel/Library/Caches/JetBrains/Fleet/backend/KMPNotifierTest.ep2jv5j26q040f498ad9/DerivedData/iosApp-ddgrzpipzoxfiieeifejojlabfys/Build/Intermediates.noindex/EagerLinkingTBDs/Debug-iphonesimulator -F/Users/krajchel/Library/Caches/JetBrains/Fleet/backend/KMPNotifierTest.ep2jv5j26q040f498ad9/DerivedData/iosApp-ddgrzpipzoxfiieeifejojlabfys/Build/Products/Debug-iphonesimulator -F/Users/krajchel/Development/AndroidStudio/KMPNotifierTest/iosApp/../shared/build/xcode-frameworks/Debug/iphonesimulator17.2 -filelist /Users/krajchel/Library/Caches/JetBrains/Fleet/backend/KMPNotifierTest.ep2jv5j26q040f498ad9/DerivedData/iosApp-ddgrzpipzoxfiieeifejojlabfys/Build/Intermediates.noindex/iosApp.build/Debug-iphonesimulator/iosApp.build/Objects-normal/arm64/iosApp.LinkFileList -Xlinker -rpath -Xlinker @executable_path/Frameworks -dead_strip -Xlinker -object_path_lto -Xlinker /Users/krajchel/Library/Caches/JetBrains/Fleet/backend/KMPNotifierTest.ep2jv5j26q040f498ad9/DerivedData/iosApp-ddgrzpipzoxfiieeifejojlabfys/Build/Intermediates.noindex/iosApp.build/Debug-iphonesimulator/iosApp.build/Objects-normal/arm64/iosApp_lto.o -Xlinker -export_dynamic -Xlinker -no_deduplicate -Xlinker -objc_abi_version -Xlinker 2 -fobjc-link-runtime -L/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator -L/usr/lib/swift -Xlinker -add_ast_path -Xlinker /Users/krajchel/Library/Caches/JetBrains/Fleet/backend/KMPNotifierTest.ep2jv5j26q040f498ad9/DerivedData/iosApp-ddgrzpipzoxfiieeifejojlabfys/Build/Intermediates.noindex/iosApp.build/Debug-iphonesimulator/iosApp.build/Objects-normal/arm64/iosApp.swiftmodule -framework shared -Xlinker -sectcreate -Xlinker TEXT -Xlinker entitlements -Xlinker /Users/krajchel/Library/Caches/JetBrains/Fleet/backend/KMPNotifierTest.ep2jv5j26q040f498ad9/DerivedData/iosApp-ddgrzpipzoxfiieeifejojlabfys/Build/Intermediates.noindex/iosApp.build/Debug-iphonesimulator/iosApp.build/iosApp.app-Simulated.xcent -Xlinker -sectcreate -Xlinker TEXT -Xlinker ents_der -Xlinker /Users/krajchel/Library/Caches/JetBrains/Fleet/backend/KMPNotifierTest.ep2jv5j26q040f498ad9/DerivedData/iosApp-ddgrzpipzoxfiieeifejojlabfys/Build/Intermediates.noindex/iosApp.build/Debug-iphonesimulator/iosApp.build/iosApp.app-Simulated.xcent.der -Xlinker -no_adhoc_codesign -Xlinker -dependency_info -Xlinker /Users/krajchel/Library/Caches/JetBrains/Fleet/backend/KMPNotifierTest.ep2jv5j26q040f498ad9/DerivedData/iosApp-ddgrzpipzoxfiieeifejojlabfys/Build/Intermediates.noindex/iosApp.build/Debug-iphonesimulator/iosApp.build/Objects-normal/arm64/iosApp_dependency_info.dat -o /Users/krajchel/Library/Caches/JetBrains/Fleet/backend/KMPNotifierTest.ep2jv5j26q040f498ad9/DerivedData/iosApp-ddgrzpipzoxfiieeifejojlabfys/Build/Products/Debug-iphonesimulator/iosApp.app/iosApp

ld: Undefined symbols: The following build commands failed: _OBJCCLASS$_FIRMessaging, referenced from: in shared2 Ld /Users/krajchel/Library/Caches/JetBrains/Fleet/backend/KMPNotifierTest.ep2jv5j26q040f498ad9/DerivedData/iosApp-ddgrzpipzoxfiieeifejojlabfys/Build/Products/Debug-iphonesimulator/iosApp.app/iosApp normal (in target 'iosApp' from project 'iosApp') clang: error: linker command failed with exit code 1 (use -v to see invocation) (1 failure)

mirzemehdi commented 4 months ago

@Sabriel1984 maybe you missed this part. First, you just need to include FirebaseMessaging library to your iOS app from Xcode. I used Swift Package Manager for adding dependencies in iOS. Here's how to do it in XCode. File -> Add Package Dependencies -> Entering " https://github.com/firebase/firebase-ios-sdk" in url field -> Add Package Button. And make sure Firebase Messaging is also chosen

Sabriel1984 commented 3 months ago

Thanks for help, I'm fresh in KMM so it wasn't obvious for me that I also need to add iOS firebase sdk and which dependency solution I should use. I encounter some XCode issues but finally compilation on iOS in Xcode succeed.