MLeaksFinder 适配
2022-01-05 本文已影响0人
梦江宝鱼
创建时间: 2022年1月5日
更新时间: 2022年1月5日
Podfile install代码替换
platform :ios, '11.0'
inhibit_all_warnings!
target 'xxx' do
pod 'xxx',:path => 'xxx/xxx'
pod 'xxx','x.x.x'
...
pod 'MLeaksFinder','1.0.0',:configurations => ['Debug']
post_install do |installer|
## Fix for XCode 12.5
find_and_replace(
"Pods/FBRetainCycleDetector/FBRetainCycleDetector/Layout/Classes/FBClassStrongLayout.mm",
"layoutCache[currentClass] = ivars;",
"layoutCache[(id<NSCopying>)currentClass] = ivars;"
)
## Fix for XCode 13.0
find_and_replace(
"Pods/FBRetainCycleDetector/fishhook/fishhook.c",
"indirect_symbol_bindings[i] = cur->rebindings[j].replacement;",
"if (i < (sizeof(indirect_symbol_bindings) / sizeof(indirect_symbol_bindings[0]))) {
indirect_symbol_bindings[i] = cur->rebindings[j].replacement;
}"
)
## Fix for iOS 11.0
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
if config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'].to_f < 11.0
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '11.0'
end
end
end
end
def find_and_replace(dir, findstr, replacestr)
Dir[dir].each do |name|
text = File.read(name)
replace = text.gsub(findstr,replacestr)
if text != replace
puts "Fix: " + name
File.open(name, "w") { |file| file.puts replace }
STDOUT.flush
end
end
Dir[dir + '*/'].each(&method(:find_and_replace))
end
end
UIAlertView 升级
MLeaksMessenger.m line:19
+ (void)alertWithTitle:(NSString *)title
message:(NSString *)message
delegate:(id<UIAlertViewDelegate>)delegate
additionalButtonTitle:(NSString *)additionalButtonTitle {
// [alertView dismissWithClickedButtonIndex:0 animated:NO];
// UIAlertView *alertViewTemp = [[UIAlertView alloc] initWithTitle:title
// message:message
// delegate:delegate
// cancelButtonTitle:@"OK"
// otherButtonTitles:additionalButtonTitle, nil];
// [alertViewTemp show];
// alertView = alertViewTemp;
NSLog(@"%@: %@", title, message);
UIAlertController *aleView = [UIAlertController
alertControllerWithTitle:title
message:message
preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *cancel = [UIAlertAction actionWithTitle:@"OK"
style:UIAlertActionStyleCancel
handler:nil];
[aleView addAction:cancel];
[[self appRootViewController] presentViewController:aleView animated:YES completion:nil];
}
+ (UIViewController *)appRootViewController{
UIViewController *rootVC = [UIApplication sharedApplication].keyWindow.rootViewController;
UIViewController *topVC = rootVC;
while (topVC.presentedViewController) {
topVC = topVC.presentedViewController;
}
return topVC;
}