No such module 'AppTrackingTransparency' Error

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")
    }

objective-c :

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

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

Tags:

Ios

Xcode