Class: EmergeCLI::Commands::Snapshots::ValidateApp

Inherits:
GlobalOptions
  • Object
show all
Defined in:
lib/commands/snapshots/validate_app.rb

Constant Summary collapse

SWIFT_PREVIEWS_MANGLED_NAMES =

Mangled names are deterministic, no need to demangle them

[
  '_$s21DeveloperToolsSupport15PreviewRegistryMp',
  '_$s7SwiftUI15PreviewProviderMp'
].freeze

Instance Method Summary collapse

Methods inherited from GlobalOptions

#before

Instance Method Details

#call(**options) ⇒ Object



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
# File 'lib/commands/snapshots/validate_app.rb', line 22

def call(**options)
  @options = options
  before(options)

  Sync do
    binary_path = get_binary_path
    Logger.info "Found binary: #{binary_path}"

    Logger.info "Loading binary: #{binary_path}"
    macho_parser = MachOParser.new
    macho_parser.load_binary(binary_path)

    use_chained_fixups, imported_symbols = macho_parser.read_linkedit_data_command
    bound_symbols = macho_parser.read_dyld_info_only_command

    found = macho_parser.find_protocols_in_swift_proto(use_chained_fixups, imported_symbols, bound_symbols,
                                                       SWIFT_PREVIEWS_MANGLED_NAMES)

    if found
      Logger.info '✅ Found SwiftUI previews'
    else
      Logger.error '❌ No SwiftUI previews found'
    end
    found
  end
end