class CocoapodsMangle::Builder

Builds the supplied targets of a Pods Xcode project.

This is useful for building pods for mangling purposes

Constants

BUILD_DIR
BUILT_PRODUCTS_DIR

Public Class Methods

new(pods_project_path, pod_target_labels) click to toggle source

@param [String] pods_project_path

path to the pods project to build.

@param [Array<String>] pod_target_labels

the pod targets to build.
# File lib/cocoapods_mangle/builder.rb, line 16
def initialize(pods_project_path, pod_target_labels)
  @pods_project_path = pods_project_path
  @pod_target_labels = pod_target_labels
end

Public Instance Methods

binaries_to_mangle() click to toggle source

Gives the built binaries to be mangled @return [Array<String>] Paths to the build pods binaries

# File lib/cocoapods_mangle/builder.rb, line 29
def binaries_to_mangle
  static_binaries_to_mangle + dynamic_binaries_to_mangle
end
build!() click to toggle source

Build the pods project

# File lib/cocoapods_mangle/builder.rb, line 22
def build!
  FileUtils.remove_dir(BUILD_DIR, true)
  @pod_target_labels.each { |target| build_target(target) }
end

Private Instance Methods

build_target(target) click to toggle source
# File lib/cocoapods_mangle/builder.rb, line 35
def build_target(target)
  Pod::UI.message "- Building '#{target}'"
  output = `xcodebuild -project "#{@pods_project_path}" -target "#{target}" -configuration Release -sdk iphonesimulator build 2>&1`
  unless $?.success?
    raise "error: Building the Pods target '#{target}' failed.\ This is the build log:\n#{output}"
  end
end
dynamic_binaries_to_mangle() click to toggle source
# File lib/cocoapods_mangle/builder.rb, line 49
def dynamic_binaries_to_mangle
  frameworks = Dir.glob("#{BUILT_PRODUCTS_DIR}/**/*.framework")
  framework = frameworks.reject do |framework_path|
    File.basename(framework_path).start_with?('Pods_')
  end
  framework.map { |path| "#{path}/#{File.basename(path, '.framework')}" }
end
static_binaries_to_mangle() click to toggle source
# File lib/cocoapods_mangle/builder.rb, line 43
def static_binaries_to_mangle
  Dir.glob("#{BUILT_PRODUCTS_DIR}/**/*.a").reject do |binary_path|
    File.basename(binary_path).start_with?('libPods-')
  end
end