Upgrade from Xcode 15.1 to Xcode 16 results in Undefined symbol: _OBJC_CLASS_$_ADClient error
Asked Answered
C

2

7

I recently upgraded from Xcode 15.1 to Xcode 16 and now encountering the following error during build:

enter image description here

This error seems related to the ADClient class, which is part of the iAd framework that I use to request attribution details. The code was working perfectly before the upgrade, and it involves calling the requestAttributionDetails method on ADClient

Christmann answered 17/9 at 12:3 Comment(2)
Have you found its solution?Genova
@MuhammadAakif can you please check ANSWER and let me know if you found any error.Christmann
C
2

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.

enter image description here

Christmann answered 17/9 at 12:30 Comment(0)
E
1

I am creating an application on Dart/Flutter. I have updated xCode to version 16 and builds have stopped being produced. I was getting the error Undefined symbol: _OBJ C_CLASS_$_AD Client. Using a global search, I found a mention of this class only in appmetrica_plugin. I contacted the developers to update the use of the iAd Service. And a temporary solution may be to add code to the header file in your project. I added "GeneratedPluginRegistrant.h" to the end of the file =>

#pragma once
@interface ADClient : NSObject {}
+ (ADClient *)sharedClient;
- (void)requestAttributionDetailsWithBlock:(void (^)(NSDictionary<NSString *,NSObject *> * attributionDetails, NSError * error)) completionHandler;
@end
@implementation ADClient
static ADClient *sharedInstance = nil;
+ (ADClient *)sharedClient {
    if (sharedInstance == nil) {
        sharedInstance = [[ADClient alloc] init];
    }
    return sharedInstance;
}
- (void)requestAttributionDetailsWithBlock:(void (^)(NSDictionary<NSString *,NSObject *> * attributionDetails, NSError * error)) completionHandler {
}
@end
Entomo answered 27/9 at 17:55 Comment(1)
I'd love to try but, How do you prevent the GeneratedPluginRegistrant.h file from regenerating?Zeba

© 2022 - 2024 — McMap. All rights reserved.