Closed shuhang closed 5 years ago
相同问题+1
同样问题,有解决办法吗,真机可以运行,模拟器直接崩溃
Assertion failed: (NO == [udid_string isEqualToString:@"00000000-0000-0000-0000-000000000000"]), function +[UIDevice(WBSDKHelpers) getUniqueStrByUUID], file /Users/insomnia/Desktop/git_Weibo_sdk/WeiboSDKSrc/WeiboSDK/UIDevice+WBSDKHelpers.m, line 116.
问题+1,写断言可还行,一言不合就闪退。。。
解决方案: //修复iOS13下 崩溃问题 验证为:模拟器下出现
/// 交换方法实现 static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ if(@available(iOS 13.0, *)){ Method origin = class_getClassMethod([UIDevice class], NSSelectorFromString(@"getUniqueStrByUUID")); // IMP originImp = method_getImplementation(origin);
Method swizz = class_getClassMethod([self class], @selector(swizz_getUniqueStrByUUID));
//交换方法实现
method_exchangeImplementations(origin, swizz);
}
});
解决方案: //修复iOS13下 崩溃问题 验证为:模拟器下出现
if TARGET_IPHONE_SIMULATOR
/// 交换方法实现 static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ if(@available(iOS 13.0, *)){ Method origin = class_getClassMethod([UIDevice class], NSSelectorFromString(@"getUniqueStrByUUID")); // IMP originImp = method_getImplementation(origin);
Method swizz = class_getClassMethod([self class], @selector(swizz_getUniqueStrByUUID)); //交换方法实现 method_exchangeImplementations(origin, swizz); } });
pragma mark - 获取唯一标识 新浪
- (NSString )swizz_getUniqueStrByUUID{ CFUUIDRef uuidObj = CFUUIDCreate(nil);//create a new UUID //get the string representation of the UUID NSString uuidString = (__bridge_transfer NSString *)CFUUIDCreateString(nil, uuidObj); CFRelease(uuidObj); return uuidString ; }
endif
测试可以了,谢谢
UUID那里crash