弗斯特
它,例如目录下的框架,可以在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
如何
使用
[ASIdentifierManager sharedManager]
当然,在你的应用程序anywhere中,首先链接框架并成功编译它。
第二
NSClassFromString()
直呼
[ASIdentifierManager共享管理器]
在任何地方
对于前一种情况,应用程序不会加载
AdSupport
ASIdentifierManager
在您的可执行程序中,当操作系统内核加载您的程序时,可以通过打印应用程序主捆绑包路径并找到应用程序可执行文件来证明这一点
nm <path/to/executable_app> | grep "ASIdentifierManager"
,将不会在结果中找到任何内容,因为您没有
信息技术
对于后一个,尝试在可执行程序中grep相同的符号,就是这样。
nm
结果列表但内核加载包含符号的框架,请查看有关动态加载程序的更多信息
dyld
.
第三
NSClassFromString
仅检查加载的类,如果
不加载框架,它返回nil,而不尝试加载包含目标类的框架。
向前地
,除非粘贴更多关于IDFA和iOS的上下文,否则无法回忆iOS 10/11和iOS 12之间的区别
项目中的框架使用情况。这里是我的一个猜测,一些相关的库
这个
支架
框架在早期版本中,但在iOS 12中,您必须尝试在iOS 11和iOS 12中转储符号列表,并比较结果。
,我不确定你想要什么,也许你在试图避免导入
支架
框架,那么初始化
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
.