Home > Enterprise >  Swift add ATTrackingManager - cannot find key in info.plist
Swift add ATTrackingManager - cannot find key in info.plist

Time:05-31

I'm trying to add ATTrackingManager to IOS project, I'm not Swift developer so went step by step with some docs and theoretically I did everything correctly yet app still crash.

So basically I did something like this:

func handleTrackingAuth() {
     if #available(iOS 14, *) {
            ATTrackingManager.requestTrackingAuthorization { status in
                switch status {
                    case .notDetermined:
                        print("ATTrackingManagerAuthorizationStatusNotDetermined", status)
                        break
                    case .restricted:
                        print("ATTrackingManagerAuthorizationStatusRestricted", status)
                        break
                    case .denied:
                        print("ATTrackingManagerAuthorizationStatusDenied", status)
                        break
                    case .authorized:
                        print("ATTrackingManagerAuthorizationStatusAuthorized", status)
                        break
                    @unknown default:
                    print("ATTracking no data", status)
                        break
                    }
            }
        }
    }

and added it into applicationDidBecomeActive part.

Then I updated my GoogleService-Info.plist with proper key:

<key>NSUserTrackingUsageDescription</key>
<string>This app needs permission to track you across apps and websites owned by 3rd parties.</string>

yet still app crashes with error

This app has crashed because it attempted to access privacy-sensitive data without a usage description. The app's Info.plist must contain an NSUserTrackingUsageDescription key with a string value explaining to the user how the app uses this data.

I thought that perhaps Xcode didn't refresh files so I cleaned build folder and restarted Xcode yet still get same error. Does anyone know why it doesn't detect that key is added?

enter image description here

CodePudding user response:

For NSUserTrackingUsageDescription, the type should be string.

in the image, the type is showing an array. it should be a string.

  • Related