From e16232884bdfafb14e33ef72ecfb8248b36328d7 Mon Sep 17 00:00:00 2001 From: Justin Malandruccolo Date: Thu, 26 Dec 2024 10:25:37 -0800 Subject: [PATCH] Swift 6 support for App Open examples PiperOrigin-RevId: 709832864 --- .../AdManagerAppOpenExample.xcodeproj/project.pbxproj | 4 ++-- .../AdManagerAppOpenExample/AppOpenAdManager.swift | 6 ++++-- .../GoogleMobileAdsConsentManager.swift | 1 + .../AppOpenExample/AppOpenExample.xcodeproj/project.pbxproj | 4 ++-- .../AppOpenExample/AppOpenExample/AppOpenAdManager.swift | 6 ++++-- .../AppOpenExample/GoogleMobileAdsConsentManager.swift | 1 + 6 files changed, 14 insertions(+), 8 deletions(-) diff --git a/Swift/admanager/AdManagerAppOpenExample/AdManagerAppOpenExample.xcodeproj/project.pbxproj b/Swift/admanager/AdManagerAppOpenExample/AdManagerAppOpenExample.xcodeproj/project.pbxproj index 47299b7d..f7d17c93 100644 --- a/Swift/admanager/AdManagerAppOpenExample/AdManagerAppOpenExample.xcodeproj/project.pbxproj +++ b/Swift/admanager/AdManagerAppOpenExample/AdManagerAppOpenExample.xcodeproj/project.pbxproj @@ -327,7 +327,7 @@ PRODUCT_BUNDLE_IDENTIFIER = com.google.ads.AdManagerAppOpenExample; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_EMIT_LOC_STRINGS = YES; - SWIFT_VERSION = 5.0; + SWIFT_VERSION = 6.0; TARGETED_DEVICE_FAMILY = "1,2"; }; name = Debug; @@ -360,7 +360,7 @@ PRODUCT_BUNDLE_IDENTIFIER = com.google.ads.AdManagerAppOpenExample; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_EMIT_LOC_STRINGS = YES; - SWIFT_VERSION = 5.0; + SWIFT_VERSION = 6.0; TARGETED_DEVICE_FAMILY = "1,2"; }; name = Release; diff --git a/Swift/admanager/AdManagerAppOpenExample/AdManagerAppOpenExample/AppOpenAdManager.swift b/Swift/admanager/AdManagerAppOpenExample/AdManagerAppOpenExample/AppOpenAdManager.swift index 44b2e243..01a5147c 100644 --- a/Swift/admanager/AdManagerAppOpenExample/AdManagerAppOpenExample/AppOpenAdManager.swift +++ b/Swift/admanager/AdManagerAppOpenExample/AdManagerAppOpenExample/AppOpenAdManager.swift @@ -14,14 +14,16 @@ // limitations under the License. // -import GoogleMobileAds +@preconcurrency import GoogleMobileAds +@MainActor protocol AppOpenAdManagerDelegate: AnyObject { /// Method to be invoked when an app open ad life cycle is complete (i.e. dismissed or fails to /// show). func appOpenAdManagerAdDidComplete(_ appOpenAdManager: AppOpenAdManager) } +@MainActor class AppOpenAdManager: NSObject { /// Ad references in the app open beta will time out after four hours, /// but this time limit may change in future beta versions. For details, see: @@ -108,7 +110,7 @@ class AppOpenAdManager: NSObject { } } -extension AppOpenAdManager: GADFullScreenContentDelegate { +extension AppOpenAdManager: @preconcurrency GADFullScreenContentDelegate { func adWillPresentFullScreenContent(_ ad: GADFullScreenPresentingAd) { print("App open ad is will be presented.") } diff --git a/Swift/admanager/AdManagerAppOpenExample/AdManagerAppOpenExample/GoogleMobileAdsConsentManager.swift b/Swift/admanager/AdManagerAppOpenExample/AdManagerAppOpenExample/GoogleMobileAdsConsentManager.swift index 091ee3d6..b1d42b36 100644 --- a/Swift/admanager/AdManagerAppOpenExample/AdManagerAppOpenExample/GoogleMobileAdsConsentManager.swift +++ b/Swift/admanager/AdManagerAppOpenExample/AdManagerAppOpenExample/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() diff --git a/Swift/admob/AppOpenExample/AppOpenExample.xcodeproj/project.pbxproj b/Swift/admob/AppOpenExample/AppOpenExample.xcodeproj/project.pbxproj index 693259b6..dab26fff 100644 --- a/Swift/admob/AppOpenExample/AppOpenExample.xcodeproj/project.pbxproj +++ b/Swift/admob/AppOpenExample/AppOpenExample.xcodeproj/project.pbxproj @@ -326,7 +326,7 @@ PRODUCT_BUNDLE_IDENTIFIER = com.google.ads.AppOpenExample; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_EMIT_LOC_STRINGS = YES; - SWIFT_VERSION = 5.0; + SWIFT_VERSION = 6.0; TARGETED_DEVICE_FAMILY = "1,2"; }; name = Debug; @@ -358,7 +358,7 @@ PRODUCT_BUNDLE_IDENTIFIER = com.google.ads.AppOpenExample; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_EMIT_LOC_STRINGS = YES; - SWIFT_VERSION = 5.0; + SWIFT_VERSION = 6.0; TARGETED_DEVICE_FAMILY = "1,2"; }; name = Release; diff --git a/Swift/admob/AppOpenExample/AppOpenExample/AppOpenAdManager.swift b/Swift/admob/AppOpenExample/AppOpenExample/AppOpenAdManager.swift index 9df041df..c80543fb 100644 --- a/Swift/admob/AppOpenExample/AppOpenExample/AppOpenAdManager.swift +++ b/Swift/admob/AppOpenExample/AppOpenExample/AppOpenAdManager.swift @@ -14,14 +14,16 @@ // limitations under the License. // -import GoogleMobileAds +@preconcurrency import GoogleMobileAds +@MainActor protocol AppOpenAdManagerDelegate: AnyObject { /// Method to be invoked when an app open ad life cycle is complete (i.e. dismissed or fails to /// show). func appOpenAdManagerAdDidComplete(_ appOpenAdManager: AppOpenAdManager) } +@MainActor class AppOpenAdManager: NSObject { /// Ad references in the app open beta will time out after four hours, /// but this time limit may change in future beta versions. For details, see: @@ -108,7 +110,7 @@ class AppOpenAdManager: NSObject { } } -extension AppOpenAdManager: GADFullScreenContentDelegate { +extension AppOpenAdManager: @preconcurrency GADFullScreenContentDelegate { func adWillPresentFullScreenContent(_ ad: GADFullScreenPresentingAd) { print("App open ad is will be presented.") } diff --git a/Swift/admob/AppOpenExample/AppOpenExample/GoogleMobileAdsConsentManager.swift b/Swift/admob/AppOpenExample/AppOpenExample/GoogleMobileAdsConsentManager.swift index 091ee3d6..b1d42b36 100644 --- a/Swift/admob/AppOpenExample/AppOpenExample/GoogleMobileAdsConsentManager.swift +++ b/Swift/admob/AppOpenExample/AppOpenExample/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()