2025最新DoKit 库在iOS18 以上系统崩溃解决办法

项目虽然是swift 项目,但是依然可以使用DoKit 集成工具来排查内存泄漏bug. 采用pod 引入:

  pod 'DoraemonKit/Core', '~> 3.0.4', :configurations => ['Debug']
  pod 'DoraemonKit/WithMLeaksFinder', '~> 3.0.4', :configurations => ['Debug']

原因是这个类DoraemonHomeViewController 有崩溃,由于是pod 引入,又是涉及到多人开发,所以不能直接修改框架源码,只能在podfile中添加ruby脚本来修复;
解决办法: 在podfile中添加如下脚本

 def find_and_replace(file_path, find_text, replace_text)
    text = File.read(file_path)
    unless text.include?(replace_text)
      new_contents = text.gsub(find_text, replace_text)
      File.open(file_path, "w") { |f| f.puts new_contents }
    end
  end


  file_path = "Pods/DoraemonKit/iOS/DoraemonKit/Src/Core/Entry/Home/DoraemonHomeViewController.m"
  find_text = "- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {\n    DoraemonHomeCell *cell = [self.collectionView dequeueReusableCellWithReuseIdentifier:DoraemonHomeCellID forIndexPath:indexPath];\n    NSInteger row = indexPath.row;\n    NSInteger section = indexPath.section;\n    \n    if (section < _dataArray.count) {"
  replacement_text = "- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {\n    NSInteger row = indexPath.row;\n    NSInteger section = indexPath.section;\n    \n    if (section < _dataArray.count) {\n        DoraemonHomeCell *cell = [self.collectionView dequeueReusableCellWithReuseIdentifier:DoraemonHomeCellID forIndexPath:indexPath];"

  find_and_replace(file_path, find_text, replacement_text)
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容