From be6751851aaa12b26ab0c0abb6372638b4631901 Mon Sep 17 00:00:00 2001 From: Justin Malandruccolo Date: Thu, 26 Dec 2024 07:22:18 -0800 Subject: [PATCH] Swift 6 support for Banner examples PiperOrigin-RevId: 709799938 --- .../AdManagerBannerExample.xcodeproj/project.pbxproj | 4 ++-- .../GoogleMobileAdsConsentManager.swift | 3 ++- .../AdManagerBannerExample/ViewController.swift | 2 +- .../BannerExample/BannerExample.xcodeproj/project.pbxproj | 4 ++-- .../BannerExample/GoogleMobileAdsConsentManager.swift | 3 ++- Swift/admob/BannerExample/BannerExample/ViewController.swift | 2 +- 6 files changed, 10 insertions(+), 8 deletions(-) diff --git a/Swift/admanager/AdManagerBannerExample/AdManagerBannerExample.xcodeproj/project.pbxproj b/Swift/admanager/AdManagerBannerExample/AdManagerBannerExample.xcodeproj/project.pbxproj index 800dc552..73d97dfd 100644 --- a/Swift/admanager/AdManagerBannerExample/AdManagerBannerExample.xcodeproj/project.pbxproj +++ b/Swift/admanager/AdManagerBannerExample/AdManagerBannerExample.xcodeproj/project.pbxproj @@ -285,7 +285,7 @@ PRODUCT_BUNDLE_IDENTIFIER = "com.google.ads.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_SWIFT3_OBJC_INFERENCE = Default; - SWIFT_VERSION = 5.0; + SWIFT_VERSION = 6.0; }; name = Debug; }; @@ -306,7 +306,7 @@ PRODUCT_BUNDLE_IDENTIFIER = "com.google.ads.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_SWIFT3_OBJC_INFERENCE = Default; - SWIFT_VERSION = 5.0; + SWIFT_VERSION = 6.0; }; name = Release; }; diff --git a/Swift/admanager/AdManagerBannerExample/AdManagerBannerExample/GoogleMobileAdsConsentManager.swift b/Swift/admanager/AdManagerBannerExample/AdManagerBannerExample/GoogleMobileAdsConsentManager.swift index 091ee3d6..963b8b4f 100644 --- a/Swift/admanager/AdManagerBannerExample/AdManagerBannerExample/GoogleMobileAdsConsentManager.swift +++ b/Swift/admanager/AdManagerBannerExample/AdManagerBannerExample/GoogleMobileAdsConsentManager.swift @@ -23,6 +23,7 @@ import UserMessagingPlatform /// consent for users in GDPR impacted countries. This is an example and /// you can choose another consent management platform to capture consent. +@MainActor class GoogleMobileAdsConsentManager: NSObject { static let shared = GoogleMobileAdsConsentManager() @@ -54,7 +55,7 @@ class GoogleMobileAdsConsentManager: NSObject { return consentGatheringComplete(requestConsentError) } - Task { @MainActor in + Task { do { try await UMPConsentForm.loadAndPresentIfRequired(from: viewController) // Consent has been gathered. diff --git a/Swift/admanager/AdManagerBannerExample/AdManagerBannerExample/ViewController.swift b/Swift/admanager/AdManagerBannerExample/AdManagerBannerExample/ViewController.swift index d71d0d44..226cecc4 100644 --- a/Swift/admanager/AdManagerBannerExample/AdManagerBannerExample/ViewController.swift +++ b/Swift/admanager/AdManagerBannerExample/AdManagerBannerExample/ViewController.swift @@ -17,7 +17,7 @@ import GoogleMobileAds import UIKit -class ViewController: UIViewController, GADBannerViewDelegate { +class ViewController: UIViewController, @preconcurrency GADBannerViewDelegate { @IBOutlet weak var bannerView: GAMBannerView! @IBOutlet weak var privacySettingsButton: UIBarButtonItem! @IBOutlet weak var adInspectorButton: UIBarButtonItem! diff --git a/Swift/admob/BannerExample/BannerExample.xcodeproj/project.pbxproj b/Swift/admob/BannerExample/BannerExample.xcodeproj/project.pbxproj index 481aa648..61d9837d 100644 --- a/Swift/admob/BannerExample/BannerExample.xcodeproj/project.pbxproj +++ b/Swift/admob/BannerExample/BannerExample.xcodeproj/project.pbxproj @@ -291,7 +291,7 @@ PRODUCT_BUNDLE_IDENTIFIER = com.google.ads.BannerExample; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_SWIFT3_OBJC_INFERENCE = Default; - SWIFT_VERSION = 5.0; + SWIFT_VERSION = 6.0; }; name = Debug; }; @@ -311,7 +311,7 @@ PRODUCT_BUNDLE_IDENTIFIER = com.google.ads.BannerExample; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_SWIFT3_OBJC_INFERENCE = Default; - SWIFT_VERSION = 5.0; + SWIFT_VERSION = 6.0; }; name = Release; }; diff --git a/Swift/admob/BannerExample/BannerExample/GoogleMobileAdsConsentManager.swift b/Swift/admob/BannerExample/BannerExample/GoogleMobileAdsConsentManager.swift index ab69cd27..e27c9ecc 100644 --- a/Swift/admob/BannerExample/BannerExample/GoogleMobileAdsConsentManager.swift +++ b/Swift/admob/BannerExample/BannerExample/GoogleMobileAdsConsentManager.swift @@ -23,6 +23,7 @@ import UserMessagingPlatform /// consent for users in GDPR impacted countries. This is an example and /// you can choose another consent management platform to capture consent. +@MainActor class GoogleMobileAdsConsentManager: NSObject { static let shared = GoogleMobileAdsConsentManager() @@ -58,7 +59,7 @@ class GoogleMobileAdsConsentManager: NSObject { return consentGatheringComplete(requestConsentError) } - Task { @MainActor in + Task { do { // [START load_and_present_consent_form] try await UMPConsentForm.loadAndPresentIfRequired(from: viewController) diff --git a/Swift/admob/BannerExample/BannerExample/ViewController.swift b/Swift/admob/BannerExample/BannerExample/ViewController.swift index 71c36eaf..591574dd 100644 --- a/Swift/admob/BannerExample/BannerExample/ViewController.swift +++ b/Swift/admob/BannerExample/BannerExample/ViewController.swift @@ -17,7 +17,7 @@ import GoogleMobileAds import UIKit -class ViewController: UIViewController, GADBannerViewDelegate { +class ViewController: UIViewController, @preconcurrency GADBannerViewDelegate { @IBOutlet weak var bannerView: GADBannerView! @IBOutlet weak var privacySettingsButton: UIBarButtonItem!