Method: CocoapodsMangle::Defines.constants

Defined in:
lib/cocoapods_mangle/defines.rb

.constants(binaries) ⇒ Array<String>

Get the constants defined in a list of binaries

Parameters:

  • binaries (Array<String>)

    The binaries containing symbols to be mangled

Returns:

  • (Array<String>)

    The constants defined in the binaries



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/cocoapods_mangle/defines.rb', line 39

def self.constants(binaries)
  all_symbols = run_nm(binaries, '-gU')
  all_symbols = all_symbols.reject { |symbol| swift_symbol?(symbol) }

  consts = all_symbols.select { |const| const[/ S /] }
  consts = consts.reject { |const| const[/_OBJC_/] }
  consts = consts.reject { |const| const[/__block_descriptor.*/] }
  consts = consts.map! { |const| const.gsub(/^.* _/, '') }
  consts = consts.uniq

  other_consts = all_symbols.select { |const| const[/ T /] }
  other_consts = other_consts.reject { |const| const[/__copy_helper_block.*/] }
  other_consts = other_consts.reject { |const| const[/__destroy_helper_block.*/] }
  other_consts = other_consts.map! { |const| const.gsub(/^.* _/, '') }
  other_consts = other_consts.uniq

  consts + other_consts
end