duyduong / flutter_native_admob

Plugin to integrate native firebase admob to Flutter application
MIT License
62 stars 85 forks source link

Did the newest firebase-ios-sdk break this plugin for iOS? #83

Open sjrphx opened 3 years ago

sjrphx commented 3 years ago

I had this plugin working before migrating to the newest flutter fire components, which involved a new firebase-ios-sdk.

firebase_core_platform_interface: ^3.0.1 flutter_native_admob: ^2.1.0+3 firebase_core: ^0.7.0

Android seems to be still working, but now I'm getting a the following Xcode compilation errors:

error: cannot find type 'GADUnifiedNativeAd' in scope
        var nativeAdChanged: ((GADUnifiedNativeAd?) -> Void)?
                               ^~~~~~~~~~~~~~~~~~
    /Users/scott/Developer/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_native_admob-2.1.0+3/ios/Classes/NativeAdmobController.swift:26:19: error: cannot find type 'GADUnifiedNativeAd' in scope
        var nativeAd: GADUnifiedNativeAd? {
                      ^~~~~~~~~~~~~~~~~~
    /Users/scott/Developer/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_native_admob-2.1.0+3/ios/Classes/NativeAdmobController.swift:108:34: error: cannot find type 'GADUnifiedNativeAdLoaderDelegate' in scope
    extension NativeAdmobController: GADUnifiedNativeAdLoaderDelegate {
                                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /Users/scott/Developer/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_native_admob-2.1.0+3/ios/Classes/NativeAdmobController.swift:110:79: error: cannot find type 'GADRequestError' in scope
        func adLoader(_ adLoader: GADAdLoader, didFailToReceiveAdWithError error: GADRequestError) {
                                                                                  ^~~~~~~~~~~~~~~
    /Users/scott/Developer/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_native_admob-2.1.0+3/ios/Classes/NativeAdmobController.swift:115:65: error: cannot find type 'GADUnifiedNativeAd' in scope
        func adLoader(_ adLoader: GADAdLoader, didReceive nativeAd: GADUnifiedNativeAd) {
                                                                    ^~~~~~~~~~~~~~~~~~
    /Users/scott/Developer/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_native_admob-2.1.0+3/ios/Classes/NativeAdmobController.swift:56:30: warning: comparing non-optional value of type 'Int' to 'nil' always returns true
                    if numberAds != nil && numberAds > 1 {
                       ~~~~~~~~~ ^  ~~~
    /Users/scott/Developer/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_native_admob-2.1.0+3/ios/Classes/NativeAdmobController.swift:62:32: error: type 'Array<GADAdLoaderAdType>.ArrayLiteralElement' (aka 'GADAdLoaderAdType') has no member 'unifiedNative'
                        adTypes: [.unifiedNative], 
                                  ~^~~~~~~~~~~~~
    /Users/scott/Developer/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_native_admob-2.1.0+3/ios/Classes/NativeAdmobController.swift:65:38: error: cannot assign value of type 'NativeAdmobController' to type 'GADAdLoaderDelegate?'
                    adLoader?.delegate = self
                                         ^~~~
    /Users/scott/Developer/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_native_admob-2.1.0+3/ios/Classes/NativeAdmobController.swift:65:38: note: add missing conformance to 'GADAdLoaderDelegate' to class 'NativeAdmobController'
                    adLoader?.delegate = self
                                         ^
    /Users/scott/Developer/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_native_admob-2.1.0+3/ios/Classes/NativeAdViews/NativeAdView.swift:15:21: error: cannot find type 'GADUnifiedNativeAdView' in scope
    class NativeAdView: GADUnifiedNativeAdView {
                        ^~~~~~~~~~~~~~~~~~~~~~
    /Users/scott/Developer/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_native_admob-2.1.0+3/ios/Classes/NativeAdViews/NativeAdView.swift:116:34: error: cannot find type 'GADUnifiedNativeAd' in scope
        func setNativeAd(_ nativeAd: GADUnifiedNativeAd?) {
                                     ^~~~~~~~~~~~~~~~~~
    /Users/scott/Developer/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_native_admob-2.1.0+3/ios/Classes/NativeAdViews/NativeAdView.swift:108:9: error: 'super' members cannot be referenced in a root class
            super.init(frame: frame)
            ^
    /Users/scott/Developer/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_native_admob-2.1.0+3/ios/Classes/NativeAdViews/NativeAdView.swift:169:9: error: cannot find 'layoutIfNeeded' in scope
            layoutIfNeeded()
            ^~~~~~~~~~~~~~
    /Users/scott/Developer/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_native_admob-2.1.0+3/ios/Classes/NativeAdViews/NativeAdView.swift:176:14: error: value of type 'NativeAdView' has no member 'mediaView'
            self.mediaView = adMediaView
            ~~~~ ^~~~~~~~~
    /Users/scott/Developer/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_native_admob-2.1.0+3/ios/Classes/NativeAdViews/NativeAdView.swift:177:14: error: value of type 'NativeAdView' has no member 'headlineView'
            self.headlineView = adHeadLineLbl
            ~~~~ ^~~~~~~~~~~~
    /Users/scott/Developer/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_native_admob-2.1.0+3/ios/Classes/NativeAdViews/NativeAdView.swift:178:14: error: value of type 'NativeAdView' has no member 'callToActionView'
            self.callToActionView = callToActionBtn
            ~~~~ ^~~~~~~~~~~~~~~~
    /Users/scott/Developer/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_native_admob-2.1.0+3/ios/Classes/NativeAdViews/NativeAdView.swift:179:14: error: value of type 'NativeAdView' has no member 'iconView'
            self.iconView = adIconView
            ~~~~ ^~~~~~~~
    /Users/scott/Developer/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_native_admob-2.1.0+3/ios/Classes/NativeAdViews/NativeAdView.swift:180:14: error: value of type 'NativeAdView' has no member 'bodyView'
            self.bodyView = adBodyLbl
            ~~~~ ^~~~~~~~
    /Users/scott/Developer/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_native_admob-2.1.0+3/ios/Classes/NativeAdViews/NativeAdView.swift:181:14: error: value of type 'NativeAdView' has no member 'storeView'
            self.storeView = adStoreLbl
            ~~~~ ^~~~~~~~~
    /Users/scott/Developer/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_native_admob-2.1.0+3/ios/Classes/NativeAdViews/NativeAdView.swift:182:14: error: value of type 'NativeAdView' has no member 'priceView'
            self.priceView = adPriceLbl
            ~~~~ ^~~~~~~~~
    /Users/scott/Developer/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_native_admob-2.1.0+3/ios/Classes/NativeAdViews/NativeAdView.swift:183:14: error: value of type 'NativeAdView' has no member 'starRatingView'
            self.starRatingView = adRatingView
            ~~~~ ^~~~~~~~~~~~~~
    /Users/scott/Developer/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_native_admob-2.1.0+3/ios/Classes/NativeAdViews/NativeAdView.swift:184:14: error: value of type 'NativeAdView' has no member 'advertiserView'
            self.advertiserView = adAdvertiserLbl
            ~~~~ ^~~~~~~~~~~~~~
    /Users/scott/Developer/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_native_admob-2.1.0+3/ios/Classes/NativeAdViews/NativeAdView.swift:221:9: error: cannot find 'addSubview' in scope
            addSubview(adLabelView)
            ^~~~~~~~~~
    /Users/scott/Developer/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_native_admob-2.1.0+3/ios/Classes/NativeAdViews/NativeAdView.swift:226:9: error: cannot find 'addSubview' in scope
            addSubview(contentView)
            ^~~~~~~~~~
    /Users/scott/Developer/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_native_admob-2.1.0+3/ios/Classes/NativeAdViews/NativeAdView.swift:254:9: error: cannot find 'addSubview' in scope
            addSubview(adLabelView)
            ^~~~~~~~~~
    /Users/scott/Developer/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_native_admob-2.1.0+3/ios/Classes/NativeAdViews/NativeAdView.swift:259:9: error: cannot find 'addSubview' in scope
            addSubview(contentView)
            ^~~~~~~~~~
    /Users/scott/Developer/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_native_admob-2.1.0+3/ios/Classes/NativeAdViews/NativeAdView.swift:15:21: error: cannot find type 'GADUnifiedNativeAdView' in scope
    class NativeAdView: GADUnifiedNativeAdView {
                        ^~~~~~~~~~~~~~~~~~~~~~
    /Users/scott/Developer/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_native_admob-2.1.0+3/ios/Classes/NativeAdmobController.swift:25:28: error: cannot find type 'GADUnifiedNativeAd' in scope
        var nativeAdChanged: ((GADUnifiedNativeAd?) -> Void)?
                               ^~~~~~~~~~~~~~~~~~
    /Users/scott/Developer/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_native_admob-2.1.0+3/ios/Classes/NativeAdViews/NativeAdView.swift:116:34: error: cannot find type 'GADUnifiedNativeAd' in scope
        func setNativeAd(_ nativeAd: GADUnifiedNativeAd?) {
                                     ^~~~~~~~~~~~~~~~~~
    /Users/scott/Developer/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_native_admob-2.1.0+3/ios/Classes/NativeAdmobController.swift:26:19: error: cannot find type 'GADUnifiedNativeAd' in scope
        var nativeAd: GADUnifiedNativeAd? {
                      ^~~~~~~~~~~~~~~~~~
    /Users/scott/Developer/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_native_admob-2.1.0+3/ios/Classes/SwiftFlutterNativeAdmobPlugin.swift:109:16: error: cannot convert return expression of type 'NativeAdView' to return type 'UIView'
            return nativeAdView
                   ^~~~~~~~~~~~
sjrphx commented 3 years ago

This plugin did break for iOS when you use the latest Google-Mobile-Ads_SDK (8.0.0), which I believe is included in firebase_core. The workaround can be found here:

https://github.com/FirebaseExtended/flutterfire/issues/4931