Skip to content

Commit 992ef37

Browse files
committed
Upgrade GMA SDK to v12
1 parent ee3e61d commit 992ef37

File tree

13 files changed

+60
-64
lines changed

13 files changed

+60
-64
lines changed

.swiftpm/xcode/xcshareddata/xcschemes/UID2GMAPlugin.xcscheme

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,18 @@
2828
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
2929
shouldUseLaunchSchemeArgsEnv = "YES"
3030
shouldAutocreateTestPlan = "YES">
31+
<Testables>
32+
<TestableReference
33+
skipped = "NO">
34+
<BuildableReference
35+
BuildableIdentifier = "primary"
36+
BlueprintIdentifier = "UID2GMAPluginTests"
37+
BuildableName = "UID2GMAPluginTests"
38+
BlueprintName = "UID2GMAPluginTests"
39+
ReferencedContainer = "container:">
40+
</BuildableReference>
41+
</TestableReference>
42+
</Testables>
3143
</TestAction>
3244
<LaunchAction
3345
buildConfiguration = "Debug"

Development/UID2GoogleGMADevelopmentApp/UID2GoogleGMADevelopmentApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Development/UID2GoogleGMADevelopmentApp/UID2GoogleGMADevelopmentApp/AppDelegate.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
1717
// Override point for customization after application launch.
1818

1919
// Initialize Google Mobile Ads SDK
20-
GADMobileAds.sharedInstance().start()
20+
MobileAds.shared.start()
2121

2222
return true
2323
}

Development/UID2GoogleGMADevelopmentApp/UID2GoogleGMADevelopmentApp/GameViewController.swift

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import GoogleMobileAds
2424
import UID2
2525
import UIKit
2626

27-
class GameViewController: UIViewController, GADFullScreenContentDelegate {
27+
class GameViewController: UIViewController, FullScreenContentDelegate {
2828

2929
private enum GameState: Int {
3030
case notStarted
@@ -40,7 +40,7 @@ class GameViewController: UIViewController, GADFullScreenContentDelegate {
4040
private static let adIntroLength = 3.0
4141

4242
/// The rewarded interstitial ad.
43-
private var rewardedInterstitialAd: GADRewardedInterstitialAd?
43+
private var rewardedInterstitialAd: RewardedInterstitialAd?
4444

4545
/// The countdown timer.
4646
private var timer: Timer?
@@ -77,7 +77,7 @@ class GameViewController: UIViewController, GADFullScreenContentDelegate {
7777

7878
Task {
7979
await loadUID2Identity()
80-
let versionNumber = GADMobileAds.sharedInstance().versionNumber
80+
let versionNumber = MobileAds.shared.versionNumber
8181
print("Google Mobile Ads SDK version: \(versionNumber.majorVersion).\(versionNumber.minorVersion).\(versionNumber.patchVersion)")
8282
}
8383

@@ -145,9 +145,9 @@ class GameViewController: UIViewController, GADFullScreenContentDelegate {
145145
}
146146

147147
private func loadRewardedInterstitialAd() {
148-
let request = GAMRequest()
149-
GADRewardedInterstitialAd.load(
150-
withAdUnitID: "/21775744923/example/rewarded_interstitial", request: request
148+
let request = AdManagerRequest()
149+
RewardedInterstitialAd.load(
150+
with: "/21775744923/example/rewarded_interstitial", request: request
151151
) { (ad, error) in
152152
if let error = error {
153153
print("Failed to load rewarded interstitial ad with error: \(error.localizedDescription)")
@@ -240,7 +240,7 @@ class GameViewController: UIViewController, GADFullScreenContentDelegate {
240240
print("Ad wasn't ready")
241241
return
242242
}
243-
ad.present(fromRootViewController: self) {
243+
ad.present(from: self) {
244244
let reward = ad.adReward
245245
print(
246246
"Reward received with currency \(reward.amount), amount \(reward.amount.doubleValue)"
@@ -255,20 +255,19 @@ class GameViewController: UIViewController, GADFullScreenContentDelegate {
255255
startNewGame()
256256
}
257257

258-
// MARK: - GADFullScreenContentDelegate
259-
260-
func adWillPresentFullScreenContent(_ ad: GADFullScreenPresentingAd) {
258+
// MARK: - FullScreenContentDelegate
259+
260+
func adWillPresentFullScreenContent(_ ad: any FullScreenPresentingAd) {
261261
print("Ad did present full screen content.")
262262
}
263263

264-
func ad(_ ad: GADFullScreenPresentingAd, didFailToPresentFullScreenContentWithError error: Error)
265-
{
264+
func ad(_ ad: any FullScreenPresentingAd, didFailToPresentFullScreenContentWithError error: Error) {
266265
print("Ad failed to present full screen content with error \(error.localizedDescription).")
267266
self.rewardedInterstitialAd = nil
268267
self.playAgainButton.isHidden = false
269268
}
270269

271-
func adDidDismissFullScreenContent(_ ad: GADFullScreenPresentingAd) {
270+
func adDidDismissFullScreenContent(_ ad: any FullScreenPresentingAd) {
272271
print("Ad did dismiss full screen content.")
273272
self.rewardedInterstitialAd = nil
274273
self.playAgainButton.isHidden = false

Package.resolved

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ let package = Package(
1616
],
1717
dependencies: [
1818
.package(url: "https://github.com/IABTechLab/uid2-ios-sdk.git", "1.7.0" ..< "2.0.0"),
19-
.package(url: "https://github.com/googleads/swift-package-manager-google-mobile-ads.git", "10.7.0" ..< "12.0.0")
19+
.package(url: "https://github.com/googleads/swift-package-manager-google-mobile-ads.git", .upToNextMajor(from: "12.0.0"))
2020
],
2121
targets: [
2222
.target(

Sources/UID2GMAPlugin/EUIDGMAMediationAdapter.swift

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ class EUIDGMAMediationAdapter: NSObject {
1717
}
1818

1919
@available(iOS 13, *)
20-
extension EUIDGMAMediationAdapter: GADRTBAdapter {
20+
extension EUIDGMAMediationAdapter: RTBAdapter {
2121

22-
static func setUpWith(_ configuration: GADMediationServerConfiguration, completionHandler: @escaping GADMediationAdapterSetUpCompletionBlock) {
22+
static func setUp(with configuration: MediationServerConfiguration, completionHandler: @escaping GADMediationAdapterSetUpCompletionBlock) {
2323
guard isOperatingSystemSupported else {
2424
completionHandler(OperatingSystemUnsupportedError())
2525
return
@@ -30,7 +30,7 @@ extension EUIDGMAMediationAdapter: GADRTBAdapter {
3030
completionHandler(nil)
3131
}
3232

33-
func collectSignals(for params: GADRTBRequestParameters, completionHandler: @escaping GADRTBSignalCompletionHandler) {
33+
func collectSignals(for params: RTBRequestParameters, completionHandler: @escaping GADRTBSignalCompletionHandler) {
3434
guard isOperatingSystemSupported else {
3535
completionHandler(nil, OperatingSystemUnsupportedError())
3636
return
@@ -44,24 +44,24 @@ extension EUIDGMAMediationAdapter: GADRTBAdapter {
4444
}
4545
}
4646

47-
static func adapterVersion() -> GADVersionNumber {
48-
var version = GADVersionNumber()
49-
version.majorVersion = 1
47+
static func adapterVersion() -> VersionNumber {
48+
var version = VersionNumber()
49+
version.majorVersion = 2
5050
version.minorVersion = 0
51-
version.patchVersion = 1
51+
version.patchVersion = 0
5252
return version
5353
}
5454

55-
static func adSDKVersion() -> GADVersionNumber {
55+
static func adSDKVersion() -> VersionNumber {
5656
let uid2Version = UID2SDKProperties.getUID2SDKVersion()
57-
var version = GADVersionNumber()
57+
var version = VersionNumber()
5858
version.majorVersion = uid2Version.major
5959
version.minorVersion = uid2Version.minor
6060
version.patchVersion = uid2Version.patch
6161
return version
6262
}
6363

64-
static func networkExtrasClass() -> GADAdNetworkExtras.Type? {
64+
static func networkExtrasClass() -> AdNetworkExtras.Type? {
6565
return nil
6666
}
6767

Sources/UID2GMAPlugin/UID2GMAMediationAdapter.swift

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ class UID2GMAMediationAdapter: NSObject {
2020
}
2121

2222
@available(iOS 13, *)
23-
extension UID2GMAMediationAdapter: GADRTBAdapter {
23+
extension UID2GMAMediationAdapter: RTBAdapter {
2424

25-
static func setUpWith(_ configuration: GADMediationServerConfiguration, completionHandler: @escaping GADMediationAdapterSetUpCompletionBlock) {
25+
static func setUp(with configuration: MediationServerConfiguration, completionHandler: @escaping GADMediationAdapterSetUpCompletionBlock) {
2626
guard isOperatingSystemSupported else {
2727
completionHandler(OperatingSystemUnsupportedError())
2828
return
@@ -33,7 +33,7 @@ extension UID2GMAMediationAdapter: GADRTBAdapter {
3333
completionHandler(nil)
3434
}
3535

36-
func collectSignals(for params: GADRTBRequestParameters, completionHandler: @escaping GADRTBSignalCompletionHandler) {
36+
func collectSignals(for params: RTBRequestParameters, completionHandler: @escaping GADRTBSignalCompletionHandler) {
3737
guard isOperatingSystemSupported else {
3838
completionHandler(nil, OperatingSystemUnsupportedError())
3939
return
@@ -47,24 +47,24 @@ extension UID2GMAMediationAdapter: GADRTBAdapter {
4747
}
4848
}
4949

50-
static func adapterVersion() -> GADVersionNumber {
51-
var version = GADVersionNumber()
52-
version.majorVersion = 1
50+
static func adapterVersion() -> VersionNumber {
51+
var version = VersionNumber()
52+
version.majorVersion = 2
5353
version.minorVersion = 0
54-
version.patchVersion = 1
54+
version.patchVersion = 0
5555
return version
5656
}
5757

58-
static func adSDKVersion() -> GADVersionNumber {
58+
static func adSDKVersion() -> VersionNumber {
5959
let uid2Version = UID2SDKProperties.getUID2SDKVersion()
60-
var version = GADVersionNumber()
60+
var version = VersionNumber()
6161
version.majorVersion = uid2Version.major
6262
version.minorVersion = uid2Version.minor
6363
version.patchVersion = uid2Version.patch
6464
return version
6565
}
6666

67-
static func networkExtrasClass() -> GADAdNetworkExtras.Type? {
67+
static func networkExtrasClass() -> AdNetworkExtras.Type? {
6868
return nil
6969
}
7070

Tests/UID2GMAPluginTests/EUIDGMAMediationAdapterTests.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ final class EUIDGMAMediationAdapterTests: XCTestCase {
2424
)
2525
)
2626

27-
let signal = try await EUIDGMAMediationAdapter().collectSignals(for: GADRTBRequestParameters())
27+
let signal = try await EUIDGMAMediationAdapter().collectSignals(for: RTBRequestParameters())
2828

2929
// Confirm that Adapter returns expected data
3030
XCTAssertEqual("euid-test-token", signal)
@@ -36,7 +36,7 @@ final class EUIDGMAMediationAdapterTests: XCTestCase {
3636
await EUIDManager.shared.resetIdentity()
3737

3838
let result = await Task<String?, Error> {
39-
try await EUIDGMAMediationAdapter().collectSignals(for: GADRTBRequestParameters())
39+
try await EUIDGMAMediationAdapter().collectSignals(for: RTBRequestParameters())
4040
}.result
4141
XCTAssertThrowsError(try result.get()) { error in
4242
let adapterError = error as? AdvertisingTokenNotFoundError
@@ -60,7 +60,7 @@ final class EUIDGMAMediationAdapterTests: XCTestCase {
6060
)
6161

6262
let result = await Task<String?, Error> {
63-
try await EUIDGMAMediationAdapter().collectSignals(for: GADRTBRequestParameters())
63+
try await EUIDGMAMediationAdapter().collectSignals(for: RTBRequestParameters())
6464
}.result
6565
XCTAssertThrowsError(try result.get()) { error in
6666
let adapterError = error as? AdvertisingTokenNotFoundError

Tests/UID2GMAPluginTests/TestExtensions/GADRTBAdapter+TestExtensions.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
import GoogleMobileAds
66

77
/// Adds an async wrapper interface to simplify testing
8-
extension GADRTBAdapter {
9-
func collectSignals(for params: GADRTBRequestParameters) async throws -> String? {
8+
extension RTBAdapter {
9+
func collectSignals(for params: RTBRequestParameters) async throws -> String? {
1010
try await withCheckedThrowingContinuation { continuation in
1111
collectSignals(for: params, completionHandler: { signal, error in
1212
guard error == nil else {

0 commit comments

Comments
 (0)