No such module 'AppTrackingTransparency' Error

I am trying to update my Google AdMob account as Apple announced a new transparency framework that requires changes to the iOS apps with the release of iOS 14. I updated my Google AdMob pod to the latest version (7.64.0). But, when I am trying to use the following code in the App Delegate:-

import AppTrackingTransparency
import AdSupport
...
func requestIDFA() {
    ATTrackingManager.requestTrackingAuthorization(completionHandler: { status in
    // Tracking authorization completed. Start loading ads here.
    // loadAd()
    })
}

I get the following error:-

No such module 'AppTrackingTransparency'

Any help would be highly appreciated!!🙏


Solution 1:

it's only available starting from Xcode 12, including beta version.

and to use it

import AppTrackingTransparency
import AdSupport

if #available(iOS 14, *) {
   ATTrackingManager.requestTrackingAuthorization(completionHandler: { status in
  // Load ads here 
   })
} else {
  // Load ads here 
}

Exmaple for RewardedVideoAdsManager

class RewardedVideoAdsManager: GADRewardedAd {


static let shared = RewardedVideoAdsManager()

var rewardedAd: GADRewardedAd?

func createAndLoadRewardedAd(unitId: String) -> GADRewardedAd? {
    rewardedAd = GADRewardedAd(adUnitID: unitId)
    let myRequest = GADRequest()
    rewardedAd?.load(myRequest) { error in
        if let error = error {
            print("Loading failed: \(error)")
        } else {
            print("Loading Succeeded")
        }
    }
    return rewardedAd
}

}

And in my AppDelegate or First main screen

    if #available(iOS 14, *) {
        ATTrackingManager.requestTrackingAuthorization(completionHandler: { status in
            RewardedVideoAdsManager.shared.rewardedAd = RewardedVideoAdsManager.shared.createAndLoadRewardedAd(unitId: "ca-app-pub-8175294120313121/4011630802")
        })
    } else {
        RewardedVideoAdsManager.shared.rewardedAd = RewardedVideoAdsManager.shared.createAndLoadRewardedAd(unitId: "ca-app-pub-8175294120313121/4011630802")
    }

Solution 2:

objective-c :

#import <AppTrackingTransparency/AppTrackingTransparency.h>
#import <AdSupport/AdSupport.h>

extern "C" void RequestIDFA()
{
    if (@available(iOS 14, *)) {
        [ATTrackingManager requestTrackingAuthorizationWithCompletionHandler:^(ATTrackingManagerAuthorizationStatus status) {
        }];
    } else {
    }
}