- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我写在这里是因为我真的被困住了,找不到答案。
我们有一个可以在里面收集 IDFA 的小框架。对于 IDFA 集合,我们首先检查 NSClassFromString(@"ASIdentifierManager")
问题是:
假设我们有一个客户端,这个客户端发布了 iOS10-iOS12 版本。并且此客户端获得了 iOS10 和 iOS11 的 IDFA,但对于所有 iOS12 根本没有 IDFA!检查日志后,我们发现 NSClassFromString(@"ASIdentifierManager")
仅适用于 iOS12..
客户端如何添加适用于 iOS10、11 而不是 iOS12 的框架?
另一方面,另一个客户端在 iOS12 上表现不错。
最佳答案
这可能无法完全回答您的问题,只是将我知道的和我的猜测发短信给您。
首先,动态框架只有在你使用时才会加载到你的app进程中,比如iOS模拟器中可用的目录下的框架设备。
> cd /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks
> # Now there are plenty of frameworks here.
> file AdSupport.framework/AdSupport
Mach-O 64-bit dynamically linked shared library x86_64
如何使用它? TLDR,用 [ASIdentifierManager sharedManager]
调用它当然,在您的任何应用程序中,首先链接到框架并成功编译它。
其次,使用NSClassFromString()
有什么区别?直接调用[ASIdentifierManager sharedManager]
任何地方?
对于前一种情况,您的应用程序不会加载 AdSupport
框架包,因为没有名为 ASIdentifierManager
的符号当操作系统内核加载你的程序时,在你的可执行程序中,可以通过打印你的应用程序主包路径并找到应用程序可执行文件来证明,尝试nm <path/to/executable_app> | grep "ASIdentifierManager"
,因为您没有使用它,所以不会在结果中找到任何东西。
对于后一种,尝试在可执行程序中grep相同的符号,就在那里。
Note: it's not os kernel loads the frameworks by
nm
result list but the kernel loads the frameworks containing the symbols, check out more info about the dynamic loader dyld.
第三,NSClassFromString
只检查加载的类,如果 AdSupport
框架没有加载,它返回 nil 而没有尝试加载包含目标类的框架。
第四,除非您粘贴有关 IDFA 和 AdSupport
的更多上下文,否则无法记忆起 iOS 10/11 和 iOS 12 之间的区别。项目中的框架使用。这是我的一个猜测,一些依赖库使用 AdSupport
框架在早期版本但 iOS 12,你必须尝试转储 iOS 11 和 iOS 12 之间的符号列表并比较结果。
第五,我不确定你想要什么,也许你想避免导入 AdSupport
显式框架,如何初始化一个NSBundle
按框架路径并调用 -(BOOL)load
的 NSBundle
类,那么你可以得到 Class
对象 NSClassFromString
.
更新:
NSString *strFrameworkPath = nil;
#if TARGET_OS_SIMULATOR
strFrameworkPath = [[NSProcessInfo processInfo] environment][@"DYLD_FALLBACK_FRAMEWORK_PATH"];
#else
// Assume that the AdSupport and Foundation framework are in the same directory.
strFrameworkPath = [NSBundle bundleForClass:NSPredicate.class].bundlePath;
strFrameworkPath = [strFrameworkPath stringByDeletingLastPathComponent];
#endif
strFrameworkPath = [strFrameworkPath stringByAppendingPathComponent:@"AdSupport.framework"];
NSAssert([[NSFileManager defaultManager] fileExistsAtPath:strFrameworkPath], @"Invalid framework bundle path!");
NSBundle *bundle = [NSBundle bundleWithPath:strFrameworkPath];
if (!bundle.isLoaded) {
NSError *error = nil;
if (![bundle loadAndReturnError:&error]) {
DDLogError(@"Load framework bundle %@ with error %@", bundle, error);
}
}
DDLogDebug(@"bundle: %@", bundle.bundlePath);
DDLogDebug(@"class: %@", NSClassFromString(@"ASIdentifierManager"));
您可能需要增强产品对各种设备的兼容性,有关NSBundle
的更多详细信息用法,查看the official documentation here .
关于ios - iOS12 中找不到 ASIdentifierManager,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53298053/
例如,我有一个父类Author: class Author { String name static hasMany = [ fiction: Book,
代码如下: dojo.query(subNav.navClass).forEach(function(node, index, arr){ if(dojo.style(node, 'd
我有一个带有 Id 和姓名的学生表和一个带有 Id 和 friend Id 的 Friends 表。我想加入这两个表并找到学生的 friend 。 例如,Ashley 的 friend 是 Saman
我通过互联网浏览,但仍未找到问题的答案。应该很容易: class Parent { String name Child child } 当我有一个 child 对象时,如何获得它的 paren
我正在尝试创建一个以 Firebase 作为我的后端的社交应用。现在我正面临如何(在哪里?)找到 friend 功能的问题。 我有每个用户的邮件地址。 我可以访问用户的电话也预订。 在传统的后端中,我
我主要想澄清以下几点: 1。有人告诉我,在 iOS 5 及以下版本中,如果您使用 Game Center 设置多人游戏,则“查找 Facebook 好友”(如与好友争夺战)的功能不是内置的,因此您需要
关于redis docker镜像ENTRYPOINT脚本 docker-entrypoint.sh : #!/bin/sh set -e # first arg is `-f` or `--some-
我是一名优秀的程序员,十分优秀!