Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NET8] Bound external constants on static libraries are being linked as non-external on the final app. #20301

Closed
Flash3001 opened this issue Mar 13, 2024 · 4 comments

Comments

@Flash3001
Copy link

Steps to Reproduce

Using NET 8

  1. dotnet new ios
  2. dotnet add package Xamarin.Google.iOS.MobileAds --version 8.13.0.3
  3. add var adType = Google.MobileAds.AdLoaderAdType.GamBanner.GetConstant() anywhere in code and run.

Expected Behavior

Google.MobileAds.AdLoaderAdType.GamBanner.GetConstant() should return a valid string.

Actual Behavior

null is returned

Environment

dotnet --version 8.0.201
running on macOS 14.3.1 (23D60)
Xcode Version 15.3 (15E204a)

The Cause

external constants in the static library (contained in a xcframework) are being imported as non-external on the final app.

GoogleMobileAds.xcframework
Screenshot 2024-03-13 at 12 35 40

My App
Screenshot 2024-03-12 at 17 51 12

This is the relevant binding: https://github.com/xamarin/GoogleApisForiOSComponents/blob/c7ae591364f73a4e61d47d765a1e537bb509422e/source/Google/MobileAds/Enums.cs#L28

Last Version it was Working?

I don't know for certain. I jumped from Xamarin.iOS straight to NET8

Example Project

linking_error.zip

Workaround

  1. Manually create a list of symbols that should be external, but aren't.
  2. Add the list to the list _CustomLinkFlags using -exported_symbols_list my_list.list
  <ItemGroup>
    <_CustomLinkFlags Include="-exported_symbols_list" />
    <_CustomLinkFlags Include="google_ads_symbols.list" />
  </ItemGroup>

My App with workaround
Screenshot 2024-03-13 at 12 36 37

Sample project with workaround implemented

linking_error_workaround.zip

@Flash3001
Copy link
Author

Just in case someone else sees the same issue and is googling about it, these are signs it is happening:

<Google> Delegate does not conform to the required protocol, nil. Add nil to Loader's protocol list.

or an exception is thrown when accessing AdSizeCons.Banner

@Flash3001
Copy link
Author

Flash3001 commented Mar 14, 2024

Update to this, the workaround works fine for debug builds, but on release builds the constants are completely missing.

Adding this extra workaround made the trick for my release builds:

        <_ReferencesLinkerFlags Include="-u_GADAdSizeFluid"  Visible="false" />
        <_ReferencesLinkerFlags Include="-u_GADAdSizeFullBanner"  Visible="false" />
        <_ReferencesLinkerFlags Include="-u_GADAdSizeInvalid"  Visible="false" />
        <_ReferencesLinkerFlags Include="-u_GADAdSizeLargeBanner"  Visible="false" />
        <_ReferencesLinkerFlags Include="-u_GADAdSizeLeaderboard"  Visible="false" />
        <_ReferencesLinkerFlags Include="-u_GADAdSizeMediumRectangle"  Visible="false" />
        <_ReferencesLinkerFlags Include="-u_GADAdSizeFromCGSize" Visible="false" />
        <_ReferencesLinkerFlags Include="-u_GADAdSizeSkyscraper"  Visible="false" />
        <_ReferencesLinkerFlags Include="-u_kGADAdSizeSmartBannerLandscape" Visible="false" />
        <_ReferencesLinkerFlags Include="-u_kGADAdSizeSmartBannerPortrait"  Visible="false" />
        <_ReferencesLinkerFlags Include="-u_GADAdLoaderAdTypeCustomNative"  Visible="false" />
        <_ReferencesLinkerFlags Include="-u_GADAdLoaderAdTypeGAMBanner"  Visible="false" />
        <_ReferencesLinkerFlags Include="-u_GADAdLoaderAdTypeNative" Visible="false" />```

@rolfbjarne
Copy link
Member

This is a duplicate of #20061, which we've already fixed.

The fix should be included in the next .NET service release.

@rolfbjarne
Copy link
Member

Great analysis of the issue btw!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants