sinaweibosdk / weibo_ios_sdk

新浪微博 IOS SDK
http://weibo.com
Other
1.45k stars 565 forks source link

Xcode11 模拟器运行启动就crash #409

Closed shuhang closed 5 years ago

shuhang commented 5 years ago

UUID那里crash

zisulu commented 5 years ago

相同问题+1

ning1019 commented 5 years ago

同样问题,有解决办法吗,真机可以运行,模拟器直接崩溃

SHBO commented 5 years ago

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.

Napoleon-D commented 5 years ago

问题+1,写断言可还行,一言不合就闪退。。。

iOSRay commented 5 years ago

解决方案: //修复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 - 获取唯一标识 新浪

shuhang commented 5 years ago

解决方案: //修复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

测试可以了,谢谢