Class: Pod::Command::Kwai::Brizo::BuildSetting

Inherits:
Pod::Command::Kwai::Brizo show all
Defined in:
lib/cocoapods-kwai/command/brizo/build_setting.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(argv) ⇒ BuildSetting

Returns a new instance of BuildSetting.



17
18
19
20
21
22
23
24
25
26
# File 'lib/cocoapods-kwai/command/brizo/build_setting.rb', line 17

def initialize(argv)
  @project_directory = argv.option('project-directory', '.')
  @dwarf_with_dsym = argv.flag?('dwarf-with-dsym')
  @dwarf = argv.flag?('dwarf')
  @targets = argv.option('targets')
  if @targets
    @targets = @targets.split(',').map(&:strip)
  end
  super
end

Class Method Details

.optionsObject



8
9
10
11
12
13
14
15
# File 'lib/cocoapods-kwai/command/brizo/build_setting.rb', line 8

def self.options
  [
    ['--project-directory=/project/dir/', 'The path to the root of the project directory'],
    ['--dwarf-with-dsym', 'dwarf with dsym file'],
    ['--dwarf', 'dwarf'],
    ['--targets=A,B', 'target names']
  ].concat(super)
end

Instance Method Details

#runObject



28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/cocoapods-kwai/command/brizo/build_setting.rb', line 28

def run
  proj = Dir.glob(File.join(@project_directory, '*.xcodeproj')).first
  raise "没有找到 xcodeproj 文件, pwd: #{`pwd`}" unless proj
  project = Xcodeproj::Project.open(proj)
  project.targets.each do |target|
    next if @targets && !@targets.include?(target.name)
    target.build_configurations.map(&:build_settings).each do |setting|
      setting['DEBUG_INFORMATION_FORMAT'] = 'dwarf' if @dwarf
      setting['DEBUG_INFORMATION_FORMAT'] = 'dwarf-with-dsym' if @dwarf_with_dsym
    end
  end
  project.save
end