Class: Dongjia::WarningManager

Inherits:
Object
  • Object
show all
Defined in:
lib/dongjia_warning_manager.rb

Class Method Summary collapse

Class Method Details

.turn_off_warnings(turn_off, sandbox_root) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/dongjia_warning_manager.rb', line 7

def self.turn_off_warnings(turn_off, sandbox_root)
  
  return if (turn_off != true)

  Dir.foreach(sandbox_root).select{|f| f.end_with?('xcodeproj')}.each do |name|
    
    proj = Xcodeproj::Project.open(File.join(sandbox_root, name))

    if name != 'Pods.xcodeproj'
      proj.build_configurations.each do | config |
        # 强制设置 deployment 版本为 8.0
        if config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'].to_f < 8.0
          config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = "8.0"
        end
      end
    end
  
    # project 的每个 target 配置
    proj.targets.each do | target |

      next if target.name.start_with?('Pods')
      
      target.build_configurations.each do | config |
      
        # 禁用非 DJ 开头 Pod 的警告
        config.build_settings['GCC_WARN_INHIBIT_ALL_WARNINGS'] = "YES" unless target.name.start_with?('DJ')
        
        # 不检测 block 中的隐式 self 调用
        config.build_settings['CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF'] = "NO"
        
        # 不检测已废弃的方法
        config.build_settings['GCC_WARN_ABOUT_DEPRECATED_FUNCTIONS'] = "NO"
        
        # 允许 objc_msgSend
        config.build_settings['ENABLE_STRICT_OBJC_MSGSEND'] = "NO"
        
        # 不检测注释
        config.build_settings['CLANG_WARN_DOCUMENTATION_COMMENTS'] = "NO"
        
        # 不严格的原型校验
        config.build_settings['CLANG_WARN_STRICT_PROTOTYPES'] = "NO"
        
        # 强制设置 deployment 版本为 8.0
        if config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'].to_f < 8.0
            config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = "8.0"
        end

        # 关闭 bitcode
        config.build_settings['ENABLE_BITCODE'] = "NO"
      end
  
    end
  
    proj.save
  
  end

end