iosxcodeapptrackingtransparency

Is using #import <AppTrackingTransparency/AppTrackingTransparency.h> the same as linking the AppTrackingTransparency.framework?


With the ever-confusing AppTrackingTransparency setup, I have been simply adding

Privacy - Tracking Usage Description - My description

To the .plist file, as well as using

#import <AppTrackingTransparency/AppTrackingTransparency.h>

in my AppDelegate.h file.

As well as calling;

if (@available(iOS 14, *)) {
            [ATTrackingManager requestTrackingAuthorizationWithCompletionHandler:^(ATTrackingManagerAuthorizationStatus status) {
                switch (status) {
                    case ATTrackingManagerAuthorizationStatusAuthorized:
                        NSLog(@"ATTrackingManagerAuthorizationStatusAuthorized");
                        
                        break;
                    case ATTrackingManagerAuthorizationStatusDenied:
                       
                        NSLog(@"ATTrackingManagerAuthorizationStatusDenied");
                        break;
                    case ATTrackingManagerAuthorizationStatusRestricted:
                        
                        NSLog(@"ATTrackingManagerAuthorizationStatusRestricted");
                        break;
                    case ATTrackingManagerAuthorizationStatusNotDetermined:
                        
                        NSLog(@"ATTrackingManagerAuthorizationStatusNotDetermined");
                        break;
                }
            }];
        } else {
           
            // Fallback on earlier versions
        }
    
}

All has been OK with regards to compiling, and even submitting the apps, however I have now realised I have not been importing the AppTrackingTransparency.framework inside the 'Build Phases' section of Xcode.

Should I be adding this framework inside the build phases as well, is it a problem that I have not done it so far?


Solution

  • If you can successfully get your app compiled, you surely already link your app with your AppTrackingTransparency.framework in some way.

    Otherwise, you will see error message from Xcode like screenshot below:

    Xcode linking error of AppTrackingTransparency.framework

    Do you use CocoaPods, Carthage or Swift Package Manager? Maybe one of your package link to AppTrackingTransparency.framework.