Class: CocoapodsMangle::Context

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

Overview

Context for mangling

Instance Method Summary collapse

Constructor Details

#initialize(installer_context, options) ⇒ Context

Initializes the context for mangling

Parameters:

  • installer_context (Pod::Installer::PostInstallHooksContext)

    The post install context

  • options (Hash)

Options Hash (options):

  • :xcconfig_path (String)

    The path to the mangling xcconfig

  • :mangle_prefix (String)

    The prefix to prepend to mangled symbols

  • :targets (Array<String>)

    The user targets whose dependencies should be mangled



14
15
16
17
# File 'lib/cocoapods_mangle/context.rb', line 14

def initialize(installer_context, options)
  @installer_context = installer_context
  @options = options
end

Instance Method Details

#mangle_prefixString

Returns The mangle prefix to be used.

Returns:

  • (String)

    The mangle prefix to be used



26
27
28
29
# File 'lib/cocoapods_mangle/context.rb', line 26

def mangle_prefix
  return default_mangle_prefix unless @options[:mangle_prefix]
  @options[:mangle_prefix]
end

#pod_target_labelsArray<String>

Returns The targets in the pods project to be mangled.

Returns:

  • (Array<String>)

    The targets in the pods project to be mangled



37
38
39
# File 'lib/cocoapods_mangle/context.rb', line 37

def pod_target_labels
  umbrella_pod_targets.map(&:cocoapods_target_label)
end

#pod_xcconfig_pathsArray<String>

Returns Paths to all pod xcconfig files which should be updated.

Returns:

  • (Array<String>)

    Paths to all pod xcconfig files which should be updated



42
43
44
45
46
47
48
49
50
# File 'lib/cocoapods_mangle/context.rb', line 42

def pod_xcconfig_paths
  pod_xcconfigs = []
  @installer_context.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      pod_xcconfigs << config.base_configuration_reference.real_path
    end
  end
  pod_xcconfigs.uniq
end

#pods_project_pathString

Returns The path to pods project.

Returns:

  • (String)

    The path to pods project



32
33
34
# File 'lib/cocoapods_mangle/context.rb', line 32

def pods_project_path
  @installer_context.pods_project.path
end

#specs_checksumString

Returns A checksum representing the current state of the target dependencies.

Returns:

  • (String)

    A checksum representing the current state of the target dependencies



53
54
55
56
57
58
# File 'lib/cocoapods_mangle/context.rb', line 53

def specs_checksum
  gem_summary = "#{CocoapodsMangle::NAME}=#{CocoapodsMangle::VERSION}"
  specs = umbrella_pod_targets.map(&:specs).flatten.uniq
  specs_summary = specs.map(&:checksum).join(',')
  Digest::SHA1.hexdigest("#{gem_summary},#{specs_summary}")
end

#xcconfig_pathString

Returns The path to the mangle xcconfig.

Returns:

  • (String)

    The path to the mangle xcconfig



20
21
22
23
# File 'lib/cocoapods_mangle/context.rb', line 20

def xcconfig_path
  return default_xcconfig_path unless @options[:xcconfig_path]
  File.join(@installer_context.sandbox.root.parent, @options[:xcconfig_path])
end