20

我正在使用以下代码来显示用于 admob 测试应用程序的唯一标识符。

这是我的 applicationDidFinishLaunching ...

// Print IDFA (from AdSupport Framework) for iOS 6 and UDID for iOS < 6.
if (NSClassFromString(@"ASIdentifierManager")) {
    NSLog(@"GoogleAdMobAdsSDK ID for testing: %@" ,
          [[[ASIdentifierManager sharedManager] advertisingIdentifier] UUIDString]);
} else {
    NSLog(@"GoogleAdMobAdsSDK ID for testing: %@" ,
          [[UIDevice currentDevice] uniqueIdentifier]);
}

构建“使用未声明的标识符:ASIdentifierManager”时出现错误

我链接了 AdSupport 框架,并且可以访问声明标识符管理器的文件,但它仍然无法识别?

我已经清理了构建文件夹,重新启动了 xCode 相同的结果。

4

2 回答 2

54

您是否从框架中导入了标头?

#import <AdSupport/ASIdentifierManager.h>
于 2013-01-10T08:05:01.050 回答
0

感谢您的回答!如果它是一个框架添加开始路径。修复我的错误的示例是:

#import "CoreMotion/CMMotionActivityManager.h"

我不正确,因为我只添加了 .h 文件。

#import "CMMotionActivityManger.h"  ---  This was incorrect and generated an error.
于 2014-06-16T01:43:17.257 回答