googleads / googleads-mobile-unity

Official Unity Plugin for the Google Mobile Ads SDK
https://developers.google.com/admob/unity
Apache License 2.0
1.38k stars 1.08k forks source link

iOS build fails - Mediation Adapters are not compatible with Facebook SDK #2736

Closed Davidnovarro closed 1 year ago

Davidnovarro commented 1 year ago

My project uses Facebook SDK (for signing-in etc..) and Google Moblie Ads SDK with mediation adapters, the problem is that mediation adapters (Applovin 6.7.0 for example) work only when "Link Frameworks Statically" is set to true, but in that case, the game crashes because of Facebook SDK.

In case static "Link Frameworks Statically" is set to true Xcode build succeeds, but the app crashes at lunch with these exceptions: (Full Crash Log)

Library not loaded: @rpath/FBAEMKit.framework/FBAEMKit
'/System/Library/Frameworks/FBAEMKit.framework/FBAEMKit' (no such file, not in dyld cache)

In case static "Link Frameworks Statically" is set to false the Xcode fails to build with these exceptions: (Screenshot)

Undefined symbol: _CGSizeFromGADAdSize
Undefined symbol: _GADAdSizeFromCGSize
Undefined symbol: _GADClosestValidSizeForAdSizes
Undefined symbol: _NSStringFromGADAdSize
Undefined symbol: _NSValueFromGADAdSize
Linker command failed with exit code 1 (use -v to see invocation)

Versions:

Unity Engine: 2021.3.25f1
External Dependency Manager: 1.2.176
Facebook SD: 16.0.0
Google Mobile Ads: 8.2.0
Applovin Mediation Adapter: 6.7.0
Xcode: 14.3
CocoaPods: 1.12.1

I want to mention that if I remove the Applovin adapter the build works correctly when Link Frameworks Statically is set to false. It also works as expected when the Link Frameworks Statically is set to true but FB SDK is removed.

Steps to reproduce:

1) Download the minimal sample project that I've made from here: (Project Link) 2) Try o build with Xcode and run it on a device

NVentimiglia commented 1 year ago

Thank you, we are looking into this.

elena-krakhmalova commented 1 year ago

hi @NVentimiglia ! Please note that the same issue happens for DT Exchange (former Fyber) adapters. DT Exchange SDK v8.2.0+ is dynamic framework, so it cannot be linked statically. Having "Link frameworks statically" option checked in EDM iOS Resolver in Unity leads to error: [general] Error loading /var/containers/Bundle/Application/0EBA85E8-5E69-40BD-9471-0AFF269802C9/LinesDraw.app/Frameworks/UnityFramework.framework/UnityFramework (136): dlopen(/var/containers/Bundle/Application/0EBA85E8-5E69-40BD-9471-0AFF269802C9/LinesDraw.app/Frameworks/UnityFramework.framework/UnityFramework, 0x0109): Library not loaded: @rpath/IASDKCore.framework/IASDKCore Referenced from: <2DECF348-8404-36E3-B99F-B2055D7F88FD> /private/var/containers/Bundle/Application/0EBA85E8-5E69-40BD-9471-0AFF269802C9/LinesDraw.app/Frameworks/UnityFramework.framework/UnityFramework...

On the other hand having "Link frameworks statically" option unchecked in EDM iOS Resolver in Unity causes another error: "_GADAdSizeFromCGSize", referenced from: ___40-[GADMAdapterFyberBannerAd loadBannerAd]_block_invoke.24 in DTExchangeAdapter(GADMAdapterFyberBannerAd.o) "_GADClosestValidSizeForAdSizes", referenced from: ___40-[GADMAdapterFyberBannerAd loadBannerAd]_block_invoke.24 in DTExchangeAdapter(GADMAdapterFyberBannerAd.o) "_IsGADAdSizeValid", referenced from: ___40-[GADMAdapterFyberBannerAd loadBannerAd]_block_invoke.24 in DTExchangeAdapter(GADMAdapterFyberBannerAd.o) "_NSStringFromGADAdSize", referenced from: ___40-[GADMAdapterFyberBannerAd loadBannerAd]_block_invoke.24 in DTExchangeAdapter(GADMAdapterFyberBannerAd.o) "_NSValueFromGADAdSize", referenced from: ___40-[GADMAdapterFyberBannerAd loadBannerAd]_block_invoke.24 in DTExchangeAdapter(GADMAdapterFyberBannerAd.o) ld: symbol(s) not found for architecture arm64 clang: error: linker command failed with exit code 1 (use -v to see invocation)

Could you please let me know how this contradiction can be resolved? Do you plan to add any fix on your side? Do you have any ETA?

Thanks in advance!

NVentimiglia commented 1 year ago

@elena-krakhmalova Thanks for the information. We do not have an ETA right now, but we are looking into this.

elena-krakhmalova commented 1 year ago

Hi @NVentimiglia ! Appreciate your response! Could you please ping me when there any updates / resolution on your side? Thanks!

elena-krakhmalova commented 1 year ago

Hi @NVentimiglia ! Any updates from your side? Thanks!

NVentimiglia commented 1 year ago

@elena-krakhmalova No updates yet, b/284182138 is the internal ticket number for this issue.

NVentimiglia commented 1 year ago

@elena-krakhmalova

Please try again. I recently updated to the latest version of the adapters and was able to get things to build.

Here is my POD file.

source 'https://github.com/CocoaPods/Specs'
source 'https://cdn.cocoapods.org/'

platform :ios, '12.0'

target 'UnityFramework' do
  pod 'GoogleMobileAdsMediationAdColony', '4.9.0.2'
  pod 'GoogleMobileAdsMediationAppLovin', '11.9.0.0'
  pod 'GoogleMobileAdsMediationFacebook', '6.12.0.1'
  pod 'GoogleMobileAdsMediationUnity', '4.7.0.0'
  pod 'GoogleMobileAdsMediationVungle', '6.12.2.0'
  pod 'Google-Mobile-Ads-SDK', '~> 10.5'
end
target 'Unity-iPhone' do
end
use_frameworks! :linkage => :static
dimamatik commented 1 year ago

@elena-krakhmalova

Please try again. I recently updated to the latest version of the adapters and was able to get things to build.

Here is my POD file.

source 'https://github.com/CocoaPods/Specs'
source 'https://cdn.cocoapods.org/'

platform :ios, '12.0'

target 'UnityFramework' do
  pod 'GoogleMobileAdsMediationAdColony', '4.9.0.2'
  pod 'GoogleMobileAdsMediationAppLovin', '11.9.0.0'
  pod 'GoogleMobileAdsMediationFacebook', '6.12.0.1'
  pod 'GoogleMobileAdsMediationUnity', '4.7.0.0'
  pod 'GoogleMobileAdsMediationVungle', '6.12.2.0'
  pod 'Google-Mobile-Ads-SDK', '~> 10.5'
end
target 'Unity-iPhone' do
end
use_frameworks! :linkage => :static

Did you use Fasebook SDK with AppLovin Mediations? I do not see Facebook pods in your list (GoogleMobileAdsMediationFacebook is not a Facebook SDK) And yes... we have same problem with Mediations and latest Facebook SDK (16+)

NVentimiglia commented 1 year ago

@elena-krakhmalova

Yes, it is included.

image

dimamatik commented 1 year ago

so strange... our Podfile contains some FacebookSDK pods (not FBAudienceNetwork pods)

pod 'FBSDKCoreKit', '16.1.1' pod 'FBSDKCoreKit_Basics', '16.1.1' pod 'FBSDKGamingServicesKit', '16.1.1' pod 'FBSDKLoginKit', '16.1.1' pod 'FBSDKShareKit', '16.1.1'

elena-krakhmalova commented 1 year ago

Hey @NVentimiglia ! I am from Digital Turbine (DT) Exchange iOS team. I do not see in your Podfile AdMob’s adapter for DT Exchange (former company was called Fyber) SDK. Once you have this adapter, IASDKCore will be installed as dependency for adapter. IASDKCore v8.2.0+ is dynamic framework, and static linkage is not suitable for dynamic frameworks. This is the issue.

dimamatik commented 1 year ago

(Hello hello.. I am not support, I just a programmer with similar problem. I am sad I broke your conversation) (We use FasebookSDK with Applovin mediation. It works good with some different mediations, like IronSource or Vungle, but build fails with AppLovinMediationGoogleAdapter or AppLovinMediationFacebookAdapter + FasebookSDK )

elena-krakhmalova commented 1 year ago

@dimamatik i understand now! 😁Sorry! I thought you are from Google team.

dimamatik commented 1 year ago

I spent 3 days for this problem and I am happy I am not in Google team...

elena-krakhmalova commented 1 year ago

@NVentimiglia I have integrated ONLY Google's Unity Plugin and Google-DT Exchange Unity plugin in our Unity app. Then I tried first to check "Link frameworks statically" option in Unity Editor in EDM and build iOS project. In this case generated Podfile looks like this:

source 'https://github.com/CocoaPods/Specs'
source 'https://cdn.cocoapods.org/'

platform :ios, '11.0'

target 'UnityFramework' do
  pod 'GoogleMobileAdsMediationFyber', '8.2.1.0'
  pod 'Google-Mobile-Ads-SDK', '~> 10.5'
end
target 'Unity-iPhone' do
end
use_frameworks! :linkage => :static

In case I have "Link frameworks statically" option unchecked, generated Podfile looks like this:

source 'https://github.com/CocoaPods/Specs'
source 'https://cdn.cocoapods.org/'

platform :ios, '11.0'

target 'UnityFramework' do
  pod 'GoogleMobileAdsMediationFyber', '8.2.1.0'
  pod 'Google-Mobile-Ads-SDK', '~> 10.5'
end
target 'Unity-iPhone' do
end
use_frameworks!

Both cases are not suitable for DT Exchange SDK v8.2.0+. App cannot be run. Please have a look at errors, I provided them in my first comment re this issue. Do you have any ideas /plans how it should be resolved? Thanks!

elena-krakhmalova commented 1 year ago

hi @NVentimiglia! Any updates? Thanks

NVentimiglia commented 1 year ago

@elena-krakhmalova Thanks for the update, I will raise awareness of incompatibility with DT-Exchange.

elena-krakhmalova commented 1 year ago

Hey @NVentimiglia ! Any updates about ETA with fix from your side or suggestions for our publishers? This issue was opened in May, and it’s already end of July… Thanks

NVentimiglia commented 1 year ago

@elena-krakhmalova We are actively working on the issue, thank you for your patience.

NVentimiglia commented 1 year ago

@elena-krakhmalova @dimamatik @Davidnovarro

Please update to the latest version of google mobile ads for unity and the mediation adapters. The issue is fixed.

ericleich commented 1 year ago

Note that specifically what powers the fix is iOS adapter releases declaring themselves as static framework. GoogleMobileAdsMediationFacebook 6.12.0.2 did this, but AppLovin doesn't look updated yet. Also if you grab the latest .unitypackage files for those adapters, that release is separate from the iOS releases. But in the short term once the iOS release is updated you can manually update the iOS dep from the unitypackage file.

rusitschka commented 1 year ago

hi @NVentimiglia ! Please note that the same issue happens for DT Exchange (former Fyber) adapters. DT Exchange SDK v8.2.0+ is dynamic framework, so it cannot be linked statically. Having "Link frameworks statically" option checked in EDM iOS Resolver in Unity leads to error: [general] Error loading /var/containers/Bundle/Application/0EBA85E8-5E69-40BD-9471-0AFF269802C9/LinesDraw.app/Frameworks/UnityFramework.framework/UnityFramework (136): dlopen(/var/containers/Bundle/Application/0EBA85E8-5E69-40BD-9471-0AFF269802C9/LinesDraw.app/Frameworks/UnityFramework.framework/UnityFramework, 0x0109): Library not loaded: @rpath/IASDKCore.framework/IASDKCore Referenced from: <2DECF348-8404-36E3-B99F-B2055D7F88FD> /private/var/containers/Bundle/Application/0EBA85E8-5E69-40BD-9471-0AFF269802C9/LinesDraw.app/Frameworks/UnityFramework.framework/UnityFramework...

On the other hand having "Link frameworks statically" option unchecked in EDM iOS Resolver in Unity causes another error: "_GADAdSizeFromCGSize", referenced from: ___40-[GADMAdapterFyberBannerAd loadBannerAd]_block_invoke.24 in DTExchangeAdapter(GADMAdapterFyberBannerAd.o) "_GADClosestValidSizeForAdSizes", referenced from: ___40-[GADMAdapterFyberBannerAd loadBannerAd]_block_invoke.24 in DTExchangeAdapter(GADMAdapterFyberBannerAd.o) "_IsGADAdSizeValid", referenced from: ___40-[GADMAdapterFyberBannerAd loadBannerAd]_block_invoke.24 in DTExchangeAdapter(GADMAdapterFyberBannerAd.o) "_NSStringFromGADAdSize", referenced from: ___40-[GADMAdapterFyberBannerAd loadBannerAd]_block_invoke.24 in DTExchangeAdapter(GADMAdapterFyberBannerAd.o) "_NSValueFromGADAdSize", referenced from: ___40-[GADMAdapterFyberBannerAd loadBannerAd]_block_invoke.24 in DTExchangeAdapter(GADMAdapterFyberBannerAd.o) ld: symbol(s) not found for architecture arm64 clang: error: linker command failed with exit code 1 (use -v to see invocation)

Could you please let me know how this contradiction can be resolved? Do you plan to add any fix on your side? Do you have any ETA?

Thanks in advance!

We're still seeing this behavior with Unity AdMob SDK 8.5.1 and Unity DTExchange adapter 3.1.6 (native adapter versions 8.2.3.0).

Is there anything else that needs to be done to fix the issue?

elena-krakhmalova commented 1 year ago

hi @rusitschka !

I've checked with AdMob Unity plugin v8.5.1, Unity DT Exchange adapter v3.1.6 (DT Exchange SDK 8.2.3) - same configuration as you mentioned. And it works for me when Link frameworks statically options is unchecked. Please have a look at my EDM settings:

AdMob_Unity_plugin_v8_5_1_DTExchange_adapter_v3_1_6_testing

Here is generated Podfile for native project:

source 'https://github.com/CocoaPods/Specs'
source 'https://cdn.cocoapods.org/'

platform :ios, '11.0'

target 'UnityFramework' do
  pod 'GoogleMobileAdsMediationFyber', '8.2.3.0'
  pod 'Google-Mobile-Ads-SDK', '~> 10.9'
end
target 'Unity-iPhone' do
end
use_frameworks!

So seems like issue is resolved.

rusitschka commented 1 year ago

Thanks for the info @elena-krakhmalova!

I tried this but unfortunately it results in the following errors:

Screenshot 2023-08-16 at 12 06 04

Here's my Podfile:

source 'https://cdn.cocoapods.org/'
source 'https://github.com/CocoaPods/Specs'

platform :ios, '12.0'

target 'UnityFramework' do
  pod 'Firebase/Analytics', '10.7.0'
  pod 'Firebase/Core', '10.7.0'
  pod 'Firebase/Crashlytics', '10.7.0'
  pod 'Firebase/RemoteConfig', '10.7.0'
  pod 'FirebaseInstallations'
  pod 'GoogleMobileAdsMediationAppLovin', '11.10.1.0'
  pod 'GoogleMobileAdsMediationFacebook', '6.12.0.1'
  pod 'GoogleMobileAdsMediationFyber', '8.2.3.0'
  pod 'GoogleMobileAdsMediationInMobi', '10.5.4.0'
  pod 'GoogleMobileAdsMediationIronSource', '7.3.1.0.0'
  pod 'GoogleMobileAdsMediationUnity', '4.8.0.0'
  pod 'Google-Mobile-Ads-SDK', '~> 10.9'
end
target 'Unity-iPhone' do
end
use_frameworks!

Maybe one of the mediation adapters we're using does not support dynamically linked frameworks?

rusitschka commented 1 year ago

I was not able to do this as we also have Firebase in the project. Some insights why this is an issue: https://github.com/firebase/firebase-ios-sdk/blob/master/docs/firebase_in_libraries.md

I tried it anyway and adding use_modular_headers! to the Podfile made the app compile and install. But when running I'm getting a lot of "Class xxx is implemented in both ..." errors and the app crashes. Reason is in the referenced document above.

Anyone successfully made this work with Firebase?

elena-krakhmalova commented 1 year ago

Hi @rusitschka ! As far as I understood issue for you happens now due to Firebase, right? Without Firebase, with usage of “use_modular_headers!” it works for you? I tried with several adapters + Fyber adapter and it works for me with “use_modular_headers!

rusitschka commented 1 year ago

I never tried without Firebase. It's not an option - we rely on it. I found a possible workaround. Currently in soft-launch.

The issue is caused by pod GoogleMobileAdsMediationFyber >= 8.2.0.0. When downgrading to 8.1.9.1 in DTExchangeMediationDependencies.xml it works with DTExchange AdMob adapter 3.1.6.

With that patch I'm so far able to use latest AdMob stack and Firebase together with use_frameworks! :linkage => :static.

Let's see if the soft-launch is successful.

elena-krakhmalova commented 1 year ago

Hi @rusitschka ! Another solutions which may be suitable for you: 1) Mixing dynamic and static linking in CocoaPods, as described here: https://medium.com/microsoft-mobile-engineering/mixing-static-and-dynamic-linking-in-cocoapods-83b6d4252c59. 2) Add :modular_headers => true to specific pods in Podfile. Please see discussion here: https://stackoverflow.com/questions/53264846/using-static-libraries-with-cocoapods-1-5-no-such-module-at-import

rusitschka commented 1 year ago

Thanks for the suggestions! We'll try that next time. Currently the solution with downgrading DTExchange works ok for us.

elena-krakhmalova commented 1 year ago

hi @NVentimiglia ! Issue is fixed when in Podfile there is only Fyber adapter, but if there are several other adapters, than build still fails with error:

ld: Undefined symbols:
  _GADAdSizeFromCGSize, referenced from:...

Also when I use mix dynamic + static linking for Pods issue still happens as well. For example, I am interested in having such configuration to work:

source 'https://cdn.cocoapods.org/'
source 'https://github.com/CocoaPods/Specs'
plugin 'cocoapods-pod-linkage'

platform :ios, '12.0'

target 'UnityFramework' do
  pod 'Firebase/Analytics', '10.13.0'
  pod 'Firebase/Core', '10.13.0'
  pod 'Firebase/Crashlytics', '10.13.0'
  pod 'Firebase/RemoteConfig', '10.13.0'
  pod 'FirebaseInstallations'
  pod 'GoogleMobileAdsMediationAppLovin', '11.10.1.0'
  pod 'GoogleMobileAdsMediationFacebook', '6.12.0.1'
  pod 'GoogleMobileAdsMediationFyber', '8.2.4.0', :linkage => :dynamic
  pod 'GoogleMobileAdsMediationInMobi', '10.5.8.0'
  pod 'GoogleMobileAdsMediationIronSource', '7.3.1.0.0'
  pod 'GoogleMobileAdsMediationMintegral', '7.3.8.0'
  # pod 'GoogleMobileAdsMediationUnity', '4.8.0.0'
  pod 'Google-Mobile-Ads-SDK', '~> 10.9'
end
target 'Unity-iPhone' do
end
use_frameworks! :linkage => :static

Could you please fix this on your side? Meanwhile could you please tell if there is any workaround which we can do Xcode project / Pods settings in order to make it work?

Looking forward to hearing from you soon! Thanks!

zenith-jacob commented 10 months ago

Any updates?

zenith-jacob commented 8 months ago

Any updates?

l2fx6 commented 4 months ago

@zenith-jacob idk as for you, but my solution was just delete firebase and appodeal, and install it again :)