GitLiveApp / firebase-kotlin-sdk

A Kotlin-first SDK for Firebase
https://gitliveapp.github.io/firebase-kotlin-sdk/
Apache License 2.0
1.17k stars 156 forks source link

Analytics linking issues #645

Open mr-kew opened 1 month ago

mr-kew commented 1 month ago

When adding analytics to project, there is some linking issue with Xcode. My setup works fine for other libraries (like auth, firestore, storage even messaging), but not for analytics. Any help would be greatly appreciated.

My configuration looks something like this:

build.gradle.kts:

kotlin {
    cocoapods {
        framework {
            isStatic = false
        }

        pod("FirebaseCore") {
            version = "11.1.0"
            linkOnly = true
        }
        pod("FirebaseAnalytics") {
            version = "11.1.0"
            linkOnly = true
        }
    }
    sourceSets.commonMain.dependencies {
        implementation("dev.gitlive:firebase-common:2.1.0")
        implementation("dev.gitlive:firebase-analytics:2.1.0")
    }
}

Podfile:

pod 'FirebaseCore', '11.1.0'
pod 'FirebaseAnalytics', '11.1.0'

Error:

e: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld invocation reported errors

The /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld command returned non-zero exit code: 1.
output:
ld: warning: ignoring duplicate libraries: '-ldl'
Undefined symbols for architecture arm64:
  "_FIRInstallationIDDidChangeNotification", referenced from:
      +[FIRAnalytics observeFirebaseInstallationIDChanges] in FirebaseAnalytics[10](FIRAnalytics.o)
  "_GULIsLoggableLevel", referenced from:
      -[APMMonitor isLoggableLevel:] in GoogleAppMeasurement[69](APMMonitor.o)
  "_GULOSLogBasic", referenced from:
      -[APMASLLogger logMessage:logTag:messageCode:withLogLevel:] in GoogleAppMeasurement[12](APMASLLogger.o)
  "_GULOSLogError", referenced from:
      -[APMPersistentDictionary initWithFileName:] in GoogleAppMeasurement[262](APMPersistentDictionary.o)
      _APMWriteDictionaryToURL in GoogleAppMeasurement[262](APMPersistentDictionary.o)
      -[APMUserDefaults synchronize] in GoogleAppMeasurement[316](APMUserDefaults.o)
  "_GULOSLogInfo", referenced from:
      ___44+[UIViewController(APMScreenClassName) load]_block_invoke in GoogleAppMeasurement[335](UIViewController+APMScreenClassName.o)
  "_GULOSLogWarning", referenced from:
      +[APMMeasurement sharedInstance] in GoogleAppMeasurement[62](APMMeasurement.o)
      -[APMPersistentDictionary objectForKey:] in GoogleAppMeasurement[262](APMPersistentDictionary.o)
      -[APMPersistentDictionary setObject:forKey:] in GoogleAppMeasurement[262](APMPersistentDictionary.o)
      -[APMUserDefaults objectForKey:] in GoogleAppMeasurement[316](APMUserDefaults.o)
      -[APMUserDefaults setObject:forKey:] in GoogleAppMeasurement[316](APMUserDefaults.o)
      -[APMUserDefaults synchronize] in GoogleAppMeasurement[316](APMUserDefaults.o)
      ___44+[UIViewController(APMScreenClassName) load]_block_invoke in GoogleAppMeasurement[335](UIViewController+APMScreenClassName.o)
      ...
  "_GULSetLoggerLevel", referenced from:
      -[APMMonitor setDebugModeEnabled:] in GoogleAppMeasurement[69](APMMonitor.o)
      -[APMMonitor setDebugModeEnabled:] in GoogleAppMeasurement[69](APMMonitor.o)
      -[APMMonitor setVerboseLoggingEnabled:] in GoogleAppMeasurement[69](APMMonitor.o)
  "_OBJC_CLASS_$_FIRInstallations", referenced from:
       in FirebaseAnalytics[10](FIRAnalytics.o)
  "_OBJC_CLASS_$_GULAppDelegateSwizzler", referenced from:
       in GoogleAppMeasurement[7](APMAnalytics.o)
  "_OBJC_CLASS_$_GULAppEnvironmentUtil", referenced from:
       in GoogleAppMeasurement[5](APMAEU.o)
  "_OBJC_CLASS_$_GULMutableDictionary", referenced from:
       in GoogleAppMeasurement[35](APMEExperiment.o)
  "_OBJC_CLASS_$_GULNetwork", referenced from:
       in GoogleAppMeasurement[7](APMAnalytics.o)
  "_OBJC_CLASS_$_GULSwizzler", referenced from:
       in GoogleAppMeasurement[335](UIViewController+APMScreenClassName.o)
  "_kGULNetworkHTTPStatusCodeCannotAcceptTraffic", referenced from:
      -[APMETaskManager handleFetchingExperimentsResponse:data:error:] in GoogleAppMeasurement[42](APMETaskManager.o)
      -[APMMeasurement networkUploadCompletionHandlerWithResponse:error:] in GoogleAppMeasurement[62](APMMeasurement.o)
      -[APMMeasurement networkRemoteConfigFetchCompletionHandler:data:error:] in GoogleAppMeasurement[62](APMMeasurement.o)
  "_kGULNetworkHTTPStatusCodeNotFound", referenced from:
      -[APMMeasurement networkRemoteConfigFetchCompletionHandler:data:error:] in GoogleAppMeasurement[62](APMMeasurement.o)
  "_kGULNetworkHTTPStatusCodeNotModified", referenced from:
      ___37-[APMMeasurement retrievePSMResponse]_block_invoke in GoogleAppMeasurement[62](APMMeasurement.o)
      -[APMMeasurement networkRemoteConfigFetchCompletionHandler:data:error:] in GoogleAppMeasurement[62](APMMeasurement.o)
      -[APMMeasurement(SKAN) handleSKANFetchResponse:data:error:] in GoogleAppMeasurement[67](APMMeasurement+SKAN.o)
      ___46-[APMMeasurement(URL) requestDeferredDeepLink]_block_invoke in GoogleAppMeasurement[68](APMMeasurement+URL.o)
  "_kGULNetworkHTTPStatusCodeUnavailable", referenced from:
      -[APMETaskManager handleFetchingExperimentsResponse:data:error:] in GoogleAppMeasurement[42](APMETaskManager.o)
      -[APMMeasurement networkUploadCompletionHandlerWithResponse:error:] in GoogleAppMeasurement[62](APMMeasurement.o)
      -[APMMeasurement networkRemoteConfigFetchCompletionHandler:data:error:] in GoogleAppMeasurement[62](APMMeasurement.o)
  "_kGULNetworkHTTPStatusNoContent", referenced from:
      -[APMETaskManager handleFetchingExperimentsResponse:data:error:] in GoogleAppMeasurement[42](APMETaskManager.o)
      -[APMMeasurement networkUploadCompletionHandlerWithResponse:error:] in GoogleAppMeasurement[62](APMMeasurement.o)
      ___37-[APMMeasurement retrievePSMResponse]_block_invoke in GoogleAppMeasurement[62](APMMeasurement.o)
      -[APMMeasurement networkRemoteConfigFetchCompletionHandler:data:error:] in GoogleAppMeasurement[62](APMMeasurement.o)
      ___46-[APMMeasurement(URL) requestDeferredDeepLink]_block_invoke in GoogleAppMeasurement[68](APMMeasurement+URL.o)
  "_kGULNetworkHTTPStatusOK", referenced from:
      -[APMETaskManager handleFetchingExperimentsResponse:data:error:] in GoogleAppMeasurement[42](APMETaskManager.o)
      -[APMMeasurement networkUploadCompletionHandlerWithResponse:error:] in GoogleAppMeasurement[62](APMMeasurement.o)
      ___37-[APMMeasurement retrievePSMResponse]_block_invoke in GoogleAppMeasurement[62](APMMeasurement.o)
      -[APMMeasurement networkRemoteConfigFetchCompletionHandler:data:error:] in GoogleAppMeasurement[62](APMMeasurement.o)
      -[APMMeasurement(SKAN) handleSKANFetchResponse:data:error:] in GoogleAppMeasurement[67](APMMeasurement+SKAN.o)
      ___46-[APMMeasurement(URL) requestDeferredDeepLink]_block_invoke in GoogleAppMeasurement[68](APMMeasurement+URL.o)
  "_pb_decode", referenced from:
      _apmpb_decode_ad_campaign_info in GoogleAppMeasurement[79](apmpb_ad_campaign_info_decoder.o)
      _apmpb_decode_app_property in GoogleAppMeasurement[82](apmpb_app_property_decoder.o)
      _apmpb_decode_audience in GoogleAppMeasurement[85](apmpb_audience_decoder.o)
      _apmpb_decode_audience in GoogleAppMeasurement[85](apmpb_audience_decoder.o)
      _apmpb_decode_audience_leaf_filter_result in GoogleAppMeasurement[88](apmpb_audience_leaf_filter_result_decoder.o)
      _apmpb_decode_audience_leaf_filter_result in GoogleAppMeasurement[88](apmpb_audience_leaf_filter_result_decoder.o)
      _apmpb_decode_client_property in GoogleAppMeasurement[91](apmpb_client_property_decoder.o)
      _apmpb_decode_client_property in GoogleAppMeasurement[91](apmpb_client_property_decoder.o)
      ...
  "_pb_decode_varint", referenced from:
      _nano_decode_repeated_uint64 in GoogleAppMeasurement[320](decoder_common.o)
  "_pb_encode", referenced from:
      _nano_two_pass_encoding in GoogleAppMeasurement[321](encoder_common.o)
      _nano_two_pass_encoding in GoogleAppMeasurement[321](encoder_common.o)
  "_pb_encode_string", referenced from:
      _nano_encode_string in GoogleAppMeasurement[321](encoder_common.o)
  "_pb_encode_submessage", referenced from:
      _apmpb_encode_repeated_ad_campaign_info in GoogleAppMeasurement[80](apmpb_ad_campaign_info_encoder.o)
      _apmpb_encode_repeated_app_property in GoogleAppMeasurement[83](apmpb_app_property_encoder.o)
      _apmpb_encode_repeated_audience in GoogleAppMeasurement[86](apmpb_audience_encoder.o)
      _apmpb_encode_repeated_audience_leaf_filter_result in GoogleAppMeasurement[89](apmpb_audience_leaf_filter_result_encoder.o)
      _apmpb_encode_repeated_client_property in GoogleAppMeasurement[92](apmpb_client_property_encoder.o)
      _apmpb_encode_repeated_consent_config in GoogleAppMeasurement[95](apmpb_consent_config_encoder.o)
      _apmpb_encode_repeated_consent_default_entry in GoogleAppMeasurement[98](apmpb_consent_default_entry_encoder.o)
      ...
  "_pb_encode_tag_for_field", referenced from:
      _apmpb_encode_repeated_ad_campaign_info in GoogleAppMeasurement[80](apmpb_ad_campaign_info_encoder.o)
      _apmpb_encode_repeated_app_property in GoogleAppMeasurement[83](apmpb_app_property_encoder.o)
      _apmpb_encode_repeated_audience in GoogleAppMeasurement[86](apmpb_audience_encoder.o)
      _apmpb_encode_repeated_audience_leaf_filter_result in GoogleAppMeasurement[89](apmpb_audience_leaf_filter_result_encoder.o)
      _apmpb_encode_repeated_client_property in GoogleAppMeasurement[92](apmpb_client_property_encoder.o)
      _apmpb_encode_repeated_consent_config in GoogleAppMeasurement[95](apmpb_consent_config_encoder.o)
      _apmpb_encode_repeated_consent_default_entry in GoogleAppMeasurement[98](apmpb_consent_default_entry_encoder.o)
      ...
  "_pb_encode_varint", referenced from:
      _nano_encode_repeated_uint64 in GoogleAppMeasurement[321](encoder_common.o)
  "_pb_istream_from_buffer", referenced from:
      _apmpb_decode_ad_campaign_info in GoogleAppMeasurement[79](apmpb_ad_campaign_info_decoder.o)
      _apmpb_decode_app_property in GoogleAppMeasurement[82](apmpb_app_property_decoder.o)
      _apmpb_decode_audience in GoogleAppMeasurement[85](apmpb_audience_decoder.o)
      _apmpb_decode_audience in GoogleAppMeasurement[85](apmpb_audience_decoder.o)
      _apmpb_decode_audience_leaf_filter_result in GoogleAppMeasurement[88](apmpb_audience_leaf_filter_result_decoder.o)
      _apmpb_decode_audience_leaf_filter_result in GoogleAppMeasurement[88](apmpb_audience_leaf_filter_result_decoder.o)
      _apmpb_decode_client_property in GoogleAppMeasurement[91](apmpb_client_property_decoder.o)
      _apmpb_decode_client_property in GoogleAppMeasurement[91](apmpb_client_property_decoder.o)
      ...
  "_pb_ostream_from_buffer", referenced from:
      _nano_two_pass_encoding in GoogleAppMeasurement[321](encoder_common.o)
  "_pb_read", referenced from:
      _apmpb_decode_repeated_ad_campaign_info in GoogleAppMeasurement[79](apmpb_ad_campaign_info_decoder.o)
      _apmpb_decode_repeated_ad_campaign_info in GoogleAppMeasurement[79](apmpb_ad_campaign_info_decoder.o)
      _apmpb_decode_repeated_app_property in GoogleAppMeasurement[82](apmpb_app_property_decoder.o)
      _apmpb_decode_repeated_app_property in GoogleAppMeasurement[82](apmpb_app_property_decoder.o)
      _apmpb_decode_repeated_audience in GoogleAppMeasurement[85](apmpb_audience_decoder.o)
      _apmpb_decode_repeated_audience in GoogleAppMeasurement[85](apmpb_audience_decoder.o)
      _apmpb_decode_repeated_audience_leaf_filter_result in GoogleAppMeasurement[88](apmpb_audience_leaf_filter_result_decoder.o)
      _apmpb_decode_repeated_audience_leaf_filter_result in GoogleAppMeasurement[88](apmpb_audience_leaf_filter_result_decoder.o)
      ...
ld: symbol(s) not found for architecture arm64

Edit: I did find an issue related to it, where it was suggested that moving analytics into separate module could fix the issue. But I was not able to replicate that setup

mr-kew commented 1 month ago

I am willing to do a PR on this, if it's an issue with the library, because I need it working. But I sadly have no idea where to start. Can someone at least nudge me in some direction?

Does Undefined symbols for architecture _FIRInstallationIDDidChangeNotification mean that this library is using a type that does not exist in the pod, or the other way around?

eduruesta commented 4 weeks ago

Hey!! is any guide or steps to do to integrate firebase Analytics in a Compose Multiplatform project? i only added this two line in the commonMain dependencie: implementation("dev.gitlive:firebase-common:2.1.0") implementation("dev.gitlive:firebase-analytics:2.1.0")

mr-kew commented 4 weeks ago

Hello, I kinda combined the iOS and the android guides. Does yours setup work? Bear in mind that mine gives the linking error only if I go ahead and actually call the Firebase.analytics

eduruesta commented 4 weeks ago

Hey, I haven't implemented it yet! I wanted to know if there was a guide to follow to implement it in a Compose Multiplatform project. I only found this https://github.com/GitLiveApp/firebase-kotlin-sdk?tab=readme-ov-file#multiplatform

mr-kew commented 3 weeks ago

I had to integrate the official iOS & Android firebase guide as well