AdamEssenmacher / GoogleApisForiOSComponents

A community-supported fork of the abandoned Xamarin.iOS.* binding libraries from Microsoft
MIT License
63 stars 13 forks source link

[FirebaseAnalytics] GoogleAppMeasurementIdentitySupport not linked #40

Closed MarkHesselberth closed 1 month ago

MarkHesselberth commented 2 months ago

With the NuGet package AdamE.Firebase.iOS.Analytics v10.24.0.2 installed, the current line is logged on startup:

10.24.0 - [FirebaseAnalytics][I-ACS044003] GoogleAppMeasurementIdentitySupport dependency is not currently linked. IDFA will not be accessible.

I saw that a recent PR referred to a similar issue (but in the context of a user that specifically did not need the identity support): #38 That PR could probably fix the problem, but as far as I can tell this change has not been included in a release yet. I therefore attempted to create a local NuGet package for the current main branch.

However, without changes, the NuGet package that was produced seemed to lack some dependencies. Including this in our project resulted in the following error message during compilation:

Tool xcrun execution started with arguments: clang++ -F /Users/localuser/Library/Caches/XamarinBuildDownload/FAnlytcs-10.24.0/FirebaseAnalytics-10.24.0/Frameworks/FirebaseAnalytics.xcframework/ios-arm64_x86_64-simulator -framework FirebaseAnalytics [... ...] -lsqlite3 -lcompression -lz -liconv -lcompression -lobjc -exported_symbols_list obj/iPhoneSimulator/Debug/net8.0-ios/iossimulator-x64/mtouch-symbols.list -L /usr/lib/swift -L /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator -Wl,-rpath -Wl,/usr/lib/swift -Xlinker -ld_classic

Tool xcrun execution finished (exit code = 1).

ld: warning: Could not find or use auto-linked framework 'GoogleAppMeasurement'
Undefined symbols for architecture x86_64:
  "_APMAnalyticsConfiguration", referenced from:
      +[FIRAnalytics startWithConfiguration:options:] in FirebaseAnalytics(FIRAnalytics.o)
  "_APMAppMeasurementOriginFirebase", referenced from:
      +[FIRAnalytics startWithConfiguration:options:] in FirebaseAnalytics(FIRAnalytics.o)
  "_APMConsentSettings3P", referenced from:
      +[FIRAnalytics setConsent:] in FirebaseAnalytics(FIRAnalytics.o)
  "_APMFormattedEventName", referenced from:
      +[FIRAnalytics logEventWithOrigin:name:parameters:] in FirebaseAnalytics(FIRAnalytics.o)
  "_APMFormattedUserPropertyName", referenced from:
      +[FIRAnalytics setUserPropertyString:forName:] in FirebaseAnalytics(FIRAnalytics.o)
  "_APMIsAnalyticsCollectionDeactivated", referenced from:
      +[FIRAnalytics startWithConfiguration:options:] in FirebaseAnalytics(FIRAnalytics.o)
  "_APMIsAnalyticsCollectionEnabled", referenced from:
      +[FIRAnalytics startWithConfiguration:options:] in FirebaseAnalytics(FIRAnalytics.o)
  "_APMMonitorLogTagOptionKey", referenced from:
      +[FIRAnalytics startWithConfiguration:options:] in FirebaseAnalytics(FIRAnalytics.o)
  "_APMUserDataFieldEmailAddress", referenced from:
      +[FIRAnalytics initiateOnDeviceConversionMeasurementWithEmailAddress:] in FirebaseAnalytics(FIRAnalytics.o)
  "_APMUserDataFieldHashedEmailAddress", referenced from:
      +[FIRAnalytics initiateOnDeviceConversionMeasurementWithHashedEmailAddress:] in FirebaseAnalytics(FIRAnalytics.o)
  "_APMUserDataFieldHashedPhoneNumber", referenced from:
      +[FIRAnalytics initiateOnDeviceConversionMeasurementWithHashedPhoneNumber:] in FirebaseAnalytics(FIRAnalytics.o)
  "_APMUserDataFieldPhoneNumber", referenced from:
      +[FIRAnalytics initiateOnDeviceConversionMeasurementWithPhoneNumber:] in FirebaseAnalytics(FIRAnalytics.o)
  "_OBJC_CLASS_$_APMAdExposureReporter", referenced from:
      _OBJC_CLASS_$_FIRAAdExposureReporter in FirebaseAnalytics(FIRAAdExposureReporter.o)
  "_OBJC_CLASS_$_APMAnalytics", referenced from:
      objc-class-ref in FirebaseAnalytics(FIRAnalytics.o)
  "_OBJC_CLASS_$_APMConditionalUserProperty", referenced from:
      _OBJC_CLASS_$_FIRAConditionalUserProperty in FirebaseAnalytics(FIRAConditionalUserProperty.o)
  "_OBJC_CLASS_$_APMConditionalUserPropertyController", referenced from:
      _OBJC_CLASS_$_FIRAConditionalUserPropertyController in FirebaseAnalytics(FIRAConditionalUserPropertyController.o)
  "_OBJC_CLASS_$_APMEvent", referenced from:
      _OBJC_CLASS_$_FIRAEvent in FirebaseAnalytics(FIRAEvent.o)
  "_OBJC_CLASS_$_APMIdentifiers", referenced from:
      _OBJC_CLASS_$_FIRAIdentifiers in FirebaseAnalytics(FIRAIdentifiers.o)
  "_OBJC_CLASS_$_APMIdentity", referenced from:
      objc-class-ref in FirebaseAnalytics(FIRAnalytics.o)
  "_OBJC_CLASS_$_APMMeasurement", referenced from:
      objc-class-ref in FirebaseAnalytics(FIRAnalytics.o)
      objc-class-ref in FirebaseAnalytics(FIRAMeasurement.o)
      _OBJC_CLASS_$_FIRAMeasurement in FirebaseAnalytics(FIRAMeasurement.o)
  "_OBJC_CLASS_$_APMScreenViewReporter", referenced from:
      objc-class-ref in FirebaseAnalytics(FIRAScreenViewReporter.o)
      _OBJC_CLASS_$_FIRAScreenViewReporter in FirebaseAnalytics(FIRAScreenViewReporter.o)
  "_OBJC_CLASS_$_APMUserAttribute", referenced from:
      _OBJC_CLASS_$_FIRAUserAttribute in FirebaseAnalytics(FIRAUserAttribute.o)
  "_OBJC_CLASS_$_APMValue", referenced from:
      _OBJC_CLASS_$_FIRAValue in FirebaseAnalytics(FIRAValue.o)
  "_OBJC_METACLASS_$_APMAdExposureReporter", referenced from:
      _OBJC_METACLASS_$_FIRAAdExposureReporter in FirebaseAnalytics(FIRAAdExposureReporter.o)
  "_OBJC_METACLASS_$_APMConditionalUserProperty", referenced from:
      _OBJC_METACLASS_$_FIRAConditionalUserProperty in FirebaseAnalytics(FIRAConditionalUserProperty.o)
  "_OBJC_METACLASS_$_APMConditionalUserPropertyController", referenced from:
      _OBJC_METACLASS_$_FIRAConditionalUserPropertyController in FirebaseAnalytics(FIRAConditionalUserPropertyController.o)
  "_OBJC_METACLASS_$_APMEvent", referenced from:
      _OBJC_METACLASS_$_FIRAEvent in FirebaseAnalytics(FIRAEvent.o)
  "_OBJC_METACLASS_$_APMIdentifiers", referenced from:
      _OBJC_METACLASS_$_FIRAIdentifiers in FirebaseAnalytics(FIRAIdentifiers.o)
  "_OBJC_METACLASS_$_APMMeasurement", referenced from:
      _OBJC_METACLASS_$_FIRAMeasurement in FirebaseAnalytics(FIRAMeasurement.o)
  "_OBJC_METACLASS_$_APMScreenViewReporter", referenced from:
      _OBJC_METACLASS_$_FIRAScreenViewReporter in FirebaseAnalytics(FIRAScreenViewReporter.o)
  "_OBJC_METACLASS_$_APMUserAttribute", referenced from:
      _OBJC_METACLASS_$_FIRAUserAttribute in FirebaseAnalytics(FIRAUserAttribute.o)
  "_OBJC_METACLASS_$_APMValue", referenced from:
      _OBJC_METACLASS_$_FIRAValue in FirebaseAnalytics(FIRAValue.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

The line ld: warning: Could not find or use auto-linked framework 'GoogleAppMeasurement' lead me to believe that this framework should also be included. I created a quick and dirty build with both references by editing Core.targets (temporarily dropping the option to toggle the ID support):

<Target Name="_FCrDownloadedItems">
    <ItemGroup>
        <!-- From https://dl.google.com/firebase/ios/analytics/cc4d75392af34c62/GoogleAppMeasurement-10.24.0.tar.gz -->
        <NativeReference Include="$(_GoogleAppMeasurementSDKBaseFolder)GoogleAppMeasurement.xcframework">
            <Kind>Framework</Kind>
            <SmartLink>True</SmartLink>
            <ForceLoad>True</ForceLoad>
            <LinkerFlags>-ObjC -lc++ -lsqlite3 -lz</LinkerFlags>
            <Frameworks>StoreKit</Frameworks>
        </NativeReference>
        <NativeReference Include="$(_GoogleAppMeasurementSDKBaseFolder)GoogleAppMeasurementIdentitySupport.xcframework">
            <Kind>Framework</Kind>
            <SmartLink>True</SmartLink>
            <ForceLoad>True</ForceLoad>
            <LinkerFlags>-ObjC -lc++ -lsqlite3 -lz</LinkerFlags>
            <Frameworks>StoreKit GoogleAppMeasurement</Frameworks>
        </NativeReference>
    </ItemGroup>
</Target>

I updated our iOS project with the NuGet package produced by this build, and it compiled successfully. It also did not produce the logs about GoogleAppMeasurementIdentitySupport, so it seemed to fix the issue.

Do you (or does anyone else here) know anything more about the GoogleAppMeasurementIdentitySupport framework? I cannot really find any good documentation on it, so I'm not sure if my assumption that both of these frameworks should be included is correct.

rezamohamed commented 2 months ago

I'm using Plugin.Firebase which sits on top of this repo and had the same question https://github.com/TobiasBuchholz/Plugin.Firebase/issues/342

AdamEssenmacher commented 1 month ago

I think I almost have a full picture of what's going on here. The GoogleAppMeasurement binaries used to be distributed in two different frameworks: 'AdIdSupport' and 'WithoutAdIdSupport'.

In version 8.8, this was changed so that there is one regular xcframework 'GoogleAppMeasurement', and an optional 'GoogleAppMeasurementIdentitySupport'. The Microsoft team missed updating these, so as of version 8.8 the frameworks stopped getting included.

38 attempted to fix the problem, but as @MarkHesselberth has pointed out, both frameworks are needed now in the case that IdSupport is needed and GoogleAppMeasurement should always be included.

I'll put a new build together for 10.24.0.3 that should fix this and a few other bugs caught recently. While I'm in there, we'll see what we can do to get some version bumps up to 10.29 at least...

rezamohamed commented 1 month ago

Plugin.Firebase would also need to be updated in parallel right? https://github.com/TobiasBuchholz/Plugin.Firebase/issues/342

AdamEssenmacher commented 1 month ago

Plugin.Firebase would also need to be updated in parallel right? TobiasBuchholz/Plugin.Firebase#342

We could, but it's not necessary. Once released, you can just pin 10.24.0.3 (or whatever it is) in your csproj.

Plugin.Firebase imports the minimum dependencies it needs to function. Developers have the freedom (and responsibility) to manage transient dependencies in the way that best works for them.

Digifais commented 1 month ago

I think I almost have a full picture of what's going on here. The GoogleAppMeasurement binaries used to be distributed in two different frameworks: 'AdIdSupport' and 'WithoutAdIdSupport'.

In version 8.8, this was changed so that there is one regular xcframework 'GoogleAppMeasurement', and an optional 'GoogleAppMeasurementIdentitySupport'. The Microsoft team missed updating these, so as of version 8.8 the frameworks stopped getting included.

38 attempted to fix the problem, but as @MarkHesselberth has pointed out, both frameworks are needed now in the case that IdSupport is needed and GoogleAppMeasurement should always be included.

I'll put a new build together for 10.24.0.3 that should fix this and a few other bugs caught recently. While I'm in there, we'll see what we can do to get some version bumps up to 10.29 at least...

I can indeed confirm this will fix the issue mentioned here and also mentioned in #35, your reasoning is totally right!

AdamEssenmacher commented 1 month ago

This should be done now.

claudioredi commented 1 week ago

I might be missing something... I'm getting this exact error and I'm pointing to 10.29.0.1

<PackageReference Include="AdamE.Firebase.iOS.Analytics" Version="10.29.0.1" />
<PackageReference Include="AdamE.Firebase.iOS.Auth" Version="10.29.0.1" />
<PackageReference Include="AdamE.Firebase.iOS.Crashlytics" Version="10.29.0.1" />
<PackageReference Include="AdamE.Firebase.iOS.RemoteConfig" Version="10.29.0.1" />

I cleared bin/obj on all projects before running the build, I cleared nuget cache, nothing seems to work.

Is there any extra step required to get rid of this problem besides just referencing packages?

AdamEssenmacher commented 1 week ago

Be sure to clear the XamarinBuildDownloadCache too.

claudioredi commented 1 week ago

Thanks for your quick reply.

No luck for now @AdamEssenmacher even deleting XamarinBuildDownloadCache, it's weird... I thougth that maybe we were overriding _FCrDownloadedItems somewhere but I couldn't find any evidence of it. But it's really strange that I'm getting exactly the same error as I if didn't have the fix.

I'll come back to this later as it's not super high priority and will update the ticket my findings, definitively it might be something related to my project.