However, iAd is deprecated in iOS 14 and later. Apple strongly advises using the AdServices framework for attribution purposes, especially for apps targeting newer iOS versions.
Remove iAd Framework from Your Project
If you’ve added iAd in the past and no longer need it (or are migrating to AdServices), be sure to:
- Remove iAd.framework from Link Binary With Libraries.
- Remove any import iAd statements in your codebase.
- Remove any iAd related code
Switch to AdServices Framework
import the AdServices framework:
import AdServices
replace your iAd-related code with the AdServices equivalent:
if #available(iOS 14.3, *) {
do {
let attributionToken = try AAAttribution.attributionToken()
// Handle the attribution token (e.g., send it to your backend)
completion(["AttributionToken": attributionToken], nil)
} catch {
// Handle the error
completion(nil, error as NSError)
}
} else {
// Handle unsupported iOS versions
completion(nil, nil)
}
In Xcode 16, when jumping to the definition of ADClient, it is clearly marked as obsolete and no longer allowed. The recommended alternative is to use AdServices' AAAttribution for handling attribution tasks. You can see this change highlighted in the image below.