diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 56e39a68..bb829ea4 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -17,22 +17,22 @@ jobs: strategy: fail-fast: false matrix: - regex: - - "Objective-C/advanced" - - "Swift/advanced" - - "Objective-C/admob" - - "Swift/admob" - - "Objective-C/admanager" - - "Swift/admanager" + include: + - { regex: "Objective-C/advanced", xcode_version: "15.3" } + - { regex: "Swift/advanced", xcode_version: "16.0" } + - { regex: "Objective-C/admob", xcode_version: "15.3" } + - { regex: "Swift/admob", xcode_version: "16.0" } + - { regex: "Objective-C/admanager", xcode_version: "15.3" } + - { regex: "Swift/admanager", xcode_version: "16.0" } steps: - name: Clone Repo uses: actions/checkout@v1 - - name: Select the Google Mobile Ads SDK minimum Xcode version (15.3) + - name: Select an Xcode version # Available Xcode versions: # https://github.com/actions/runner-images/blob/main/images/macos/toolsets/toolset-14.json run: | - sudo xcode-select -s /Applications/Xcode_15.3.app/Contents/Developer + sudo xcode-select -s /Applications/Xcode_${{ matrix.xcode_version }}.app/Contents/Developer echo "Selected Xcode version:" /usr/bin/xcodebuild -version diff --git a/Swift/admanager/AdManagerCustomRenderingExample/AdManagerCustomRenderingExample.xcodeproj/project.pbxproj b/Swift/admanager/AdManagerCustomRenderingExample/AdManagerCustomRenderingExample.xcodeproj/project.pbxproj index 44a6b88d..b10161e9 100644 --- a/Swift/admanager/AdManagerCustomRenderingExample/AdManagerCustomRenderingExample.xcodeproj/project.pbxproj +++ b/Swift/admanager/AdManagerCustomRenderingExample/AdManagerCustomRenderingExample.xcodeproj/project.pbxproj @@ -312,7 +312,7 @@ PRODUCT_BUNDLE_IDENTIFIER = com.google.AdManagerCustomRenderingExample; PRODUCT_NAME = AdManagerCustomRenderingExample; SWIFT_SWIFT3_OBJC_INFERENCE = Default; - SWIFT_VERSION = 5.0; + SWIFT_VERSION = 6.0; }; name = Debug; }; @@ -331,7 +331,7 @@ PRODUCT_BUNDLE_IDENTIFIER = com.google.AdManagerCustomRenderingExample; PRODUCT_NAME = AdManagerCustomRenderingExample; SWIFT_SWIFT3_OBJC_INFERENCE = Default; - SWIFT_VERSION = 5.0; + SWIFT_VERSION = 6.0; }; name = Release; }; diff --git a/Swift/admanager/AdManagerCustomRenderingExample/AdManagerCustomRenderingExample/GoogleMobileAdsConsentManager.swift b/Swift/admanager/AdManagerCustomRenderingExample/AdManagerCustomRenderingExample/GoogleMobileAdsConsentManager.swift index 091ee3d6..963b8b4f 100644 --- a/Swift/admanager/AdManagerCustomRenderingExample/AdManagerCustomRenderingExample/GoogleMobileAdsConsentManager.swift +++ b/Swift/admanager/AdManagerCustomRenderingExample/AdManagerCustomRenderingExample/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/AdManagerCustomRenderingExample/AdManagerCustomRenderingExample/MySimpleNativeAdView.swift b/Swift/admanager/AdManagerCustomRenderingExample/AdManagerCustomRenderingExample/MySimpleNativeAdView.swift index 31b91f82..1ce6dfd8 100644 --- a/Swift/admanager/AdManagerCustomRenderingExample/AdManagerCustomRenderingExample/MySimpleNativeAdView.swift +++ b/Swift/admanager/AdManagerCustomRenderingExample/AdManagerCustomRenderingExample/MySimpleNativeAdView.swift @@ -45,19 +45,21 @@ class MySimpleNativeAdView: UIView { override func awakeFromNib() { super.awakeFromNib() - // Enable clicks on the main image. - mainPlaceholder.addGestureRecognizer( - UITapGestureRecognizer( - target: self, - action: #selector(performClickOnMainImage(_:)))) - mainPlaceholder.isUserInteractionEnabled = true - - // Enable clicks on AdChoices. - adChoicesView.addGestureRecognizer( - UITapGestureRecognizer( - target: self, - action: #selector(performClickOnAdChoices(_:)))) - adChoicesView.isUserInteractionEnabled = true + DispatchQueue.main.async { + // Enable clicks on the main image. + self.mainPlaceholder.addGestureRecognizer( + UITapGestureRecognizer( + target: self, + action: #selector(self.performClickOnMainImage(_:)))) + self.mainPlaceholder.isUserInteractionEnabled = true + + // Enable clicks on AdChoices. + self.adChoicesView.addGestureRecognizer( + UITapGestureRecognizer( + target: self, + action: #selector(self.performClickOnAdChoices(_:)))) + self.adChoicesView.isUserInteractionEnabled = true + } } @objc func performClickOnMainImage(_ sender: UITapGestureRecognizer!) { diff --git a/Swift/admanager/AdManagerCustomRenderingExample/AdManagerCustomRenderingExample/ViewController.swift b/Swift/admanager/AdManagerCustomRenderingExample/AdManagerCustomRenderingExample/ViewController.swift index 0e528462..5d860d27 100644 --- a/Swift/admanager/AdManagerCustomRenderingExample/AdManagerCustomRenderingExample/ViewController.swift +++ b/Swift/admanager/AdManagerCustomRenderingExample/AdManagerCustomRenderingExample/ViewController.swift @@ -232,8 +232,13 @@ class ViewController: UIViewController { // MARK: - GADAdLoaderDelegate -extension ViewController: GADAdLoaderDelegate { +#if swift(>=6) + extension ViewController: @preconcurrency GADAdLoaderDelegate {} +#else + extension ViewController: GADAdLoaderDelegate {} +#endif +extension ViewController { func adLoader(_ adLoader: GADAdLoader, didFailToReceiveAdWithError error: Error) { print("\(adLoader) failed with error: \(error.localizedDescription)") refreshAdButton.isEnabled = true @@ -242,8 +247,13 @@ extension ViewController: GADAdLoaderDelegate { // MARK: - GADNativeAdLoaderDelegate -extension ViewController: GADNativeAdLoaderDelegate { +#if swift(>=6) + extension ViewController: @preconcurrency GADNativeAdLoaderDelegate {} +#else + extension ViewController: GADNativeAdLoaderDelegate {} +#endif +extension ViewController { func adLoader(_ adLoader: GADAdLoader, didReceive nativeAd: GADNativeAd) { print("Received native ad: \(nativeAd)") refreshAdButton.isEnabled = true @@ -323,8 +333,13 @@ extension ViewController: GADNativeAdLoaderDelegate { } // MARK: - GADCustomNativeAdLoaderDelegate +#if swift(>=6) + extension ViewController: @preconcurrency GADCustomNativeAdLoaderDelegate {} +#else + extension ViewController: GACustomDNativeAdLoaderDelegate {} +#endif -extension ViewController: GADCustomNativeAdLoaderDelegate { +extension ViewController { func customNativeAdFormatIDs(for adLoader: GADAdLoader) -> [String] { return [nativeCustomFormatId] } @@ -356,16 +371,26 @@ extension ViewController: GADCustomNativeAdLoaderDelegate { } // MARK: - GADVideoControllerDelegate implementation -extension ViewController: GADVideoControllerDelegate { +#if swift(>=6) + extension ViewController: @preconcurrency GADVideoControllerDelegate {} +#else + extension ViewController: GADVideoControllerDelegate {} +#endif +extension ViewController { func videoControllerDidEndVideoPlayback(_ videoController: GADVideoController) { videoStatusLabel.text = "Video playback has ended." } } // MARK: - GADNativeAdDelegate implementation -extension ViewController: GADNativeAdDelegate { +#if swift(>=6) + extension ViewController: @preconcurrency GADNativeAdDelegate {} +#else + extension ViewController: GADNativeAdDelegate {} +#endif +extension ViewController { func nativeAdDidRecordClick(_ nativeAd: GADNativeAd) { print("\(#function) called") }