From 47add97db751f47a50d794335d7fa142b04e481a Mon Sep 17 00:00:00 2001 From: Justin Malandruccolo Date: Fri, 3 Jan 2025 09:35:42 -0800 Subject: [PATCH] Swift 6 support for interstitial examples PiperOrigin-RevId: 711776489 --- .../AdManagerInterstitialExample.xcodeproj/project.pbxproj | 4 ++-- .../GoogleMobileAdsConsentManager.swift | 3 ++- .../AdManagerInterstitialExample/ViewController.swift | 4 ++-- .../InterstitialExample.xcodeproj/project.pbxproj | 4 ++-- .../InterstitialExample/GoogleMobileAdsConsentManager.swift | 3 ++- .../InterstitialExample/ViewController.swift | 4 ++-- 6 files changed, 12 insertions(+), 10 deletions(-) diff --git a/Swift/admanager/AdManagerInterstitialExample/AdManagerInterstitialExample.xcodeproj/project.pbxproj b/Swift/admanager/AdManagerInterstitialExample/AdManagerInterstitialExample.xcodeproj/project.pbxproj index 9c1e33c7..cb890a3e 100644 --- a/Swift/admanager/AdManagerInterstitialExample/AdManagerInterstitialExample.xcodeproj/project.pbxproj +++ b/Swift/admanager/AdManagerInterstitialExample/AdManagerInterstitialExample.xcodeproj/project.pbxproj @@ -284,7 +284,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; }; @@ -304,7 +304,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/AdManagerInterstitialExample/AdManagerInterstitialExample/GoogleMobileAdsConsentManager.swift b/Swift/admanager/AdManagerInterstitialExample/AdManagerInterstitialExample/GoogleMobileAdsConsentManager.swift index 091ee3d6..963b8b4f 100644 --- a/Swift/admanager/AdManagerInterstitialExample/AdManagerInterstitialExample/GoogleMobileAdsConsentManager.swift +++ b/Swift/admanager/AdManagerInterstitialExample/AdManagerInterstitialExample/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/AdManagerInterstitialExample/AdManagerInterstitialExample/ViewController.swift b/Swift/admanager/AdManagerInterstitialExample/AdManagerInterstitialExample/ViewController.swift index cace905c..f04a59b2 100644 --- a/Swift/admanager/AdManagerInterstitialExample/AdManagerInterstitialExample/ViewController.swift +++ b/Swift/admanager/AdManagerInterstitialExample/AdManagerInterstitialExample/ViewController.swift @@ -14,10 +14,10 @@ // limitations under the License. // -import GoogleMobileAds +@preconcurrency import GoogleMobileAds import UIKit -class ViewController: UIViewController, GADFullScreenContentDelegate { +class ViewController: UIViewController, @preconcurrency GADFullScreenContentDelegate { enum GameState: NSInteger { case notStarted diff --git a/Swift/admob/InterstitialExample/InterstitialExample.xcodeproj/project.pbxproj b/Swift/admob/InterstitialExample/InterstitialExample.xcodeproj/project.pbxproj index 7fb08bf7..e75d5ca9 100644 --- a/Swift/admob/InterstitialExample/InterstitialExample.xcodeproj/project.pbxproj +++ b/Swift/admob/InterstitialExample/InterstitialExample.xcodeproj/project.pbxproj @@ -292,7 +292,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; }; @@ -312,7 +312,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/admob/InterstitialExample/InterstitialExample/GoogleMobileAdsConsentManager.swift b/Swift/admob/InterstitialExample/InterstitialExample/GoogleMobileAdsConsentManager.swift index 091ee3d6..963b8b4f 100644 --- a/Swift/admob/InterstitialExample/InterstitialExample/GoogleMobileAdsConsentManager.swift +++ b/Swift/admob/InterstitialExample/InterstitialExample/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/admob/InterstitialExample/InterstitialExample/ViewController.swift b/Swift/admob/InterstitialExample/InterstitialExample/ViewController.swift index f81d4fbd..dbc8d3f2 100644 --- a/Swift/admob/InterstitialExample/InterstitialExample/ViewController.swift +++ b/Swift/admob/InterstitialExample/InterstitialExample/ViewController.swift @@ -14,10 +14,10 @@ // limitations under the License. // -import GoogleMobileAds +@preconcurrency import GoogleMobileAds import UIKit -class ViewController: UIViewController, GADFullScreenContentDelegate { +class ViewController: UIViewController, @preconcurrency GADFullScreenContentDelegate { enum GameState: NSInteger { case notStarted