Class: Pod::Prebuild

Inherits:
Object
  • Object
show all
Defined in:
lib/cocoapods-binary/Prebuild.rb,
lib/cocoapods-binary/podfile_options.rb,
lib/cocoapods-binary/rome/build_framework.rb

Class Method Summary collapse

Class Method Details

.build(sandbox_root_path, output_path, targets) ⇒ Object

Build the frameworks with sandbox and targets

Parameters:

  • sandbox_root_path (String)

    The sandbox root path where the targets project place

    Pathname

    output_path

    output path for generated frameworks

    Array<PodTarget>

    targets

    The pod targets to build

Raises:

  • (Pod::Informative)


64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/cocoapods-binary/rome/build_framework.rb', line 64

def self.build(sandbox_root_path, output_path, targets)

  return unless not targets.empty?

  sandbox_root = Pathname(sandbox_root_path)
  sandbox = Pod::Sandbox.new(sandbox_root)

  build_dir = sandbox_root.parent + 'build'
  destination = output_path

  build_dir.rmtree if build_dir.directory?


  Pod::UI.puts "Prebuild frameworks (total #{targets.count})"

  targets.each do |target|
    case target.platform.name
    when :ios then build_for_iosish_platform(sandbox, build_dir, target, 'iphoneos', 'iphonesimulator')
    when :osx then xcodebuild(sandbox, target.label)
    when :tvos then nil
    when :watchos then nil
    # when :tvos then build_for_iosish_platform(sandbox, build_dir, target, 'appletvos', 'appletvsimulator')
    # when :watchos then build_for_iosish_platform(sandbox, build_dir, target, 'watchos', 'watchsimulator')
    else raise "Unknown platform '#{target.platform.name}'" end
  end

  raise Pod::Informative, 'The build directory was not found in the expected location.' unless build_dir.directory?

  # Make sure the device target overwrites anything in the simulator build, otherwise iTunesConnect
  # can get upset about Info.plist containing references to the simulator SDK
  frameworks = build_dir.children.select{ |path| File.extname(path) == ".framework" }
  Pod::UI.puts "Built #{frameworks.count} #{'frameworks'.pluralize(frameworks.count)}"

  targets.each do |pod_target|
      consumer = pod_target.root_spec.consumer(pod_target.platform.name)
      file_accessor = Pod::Sandbox::FileAccessor.new(sandbox.pod_dir(pod_target.pod_name), consumer)
      frameworks += file_accessor.vendored_libraries
      frameworks += file_accessor.vendored_frameworks
  end
  frameworks.uniq!

  Pod::UI.puts "Copying #{frameworks.count} #{'frameworks'.pluralize(frameworks.count)} " \
    "to `#{destination.relative_path_from Pathname.pwd}`"

  frameworks.each do |framework|
    FileUtils.mkdir_p destination
    FileUtils.cp_r framework, destination, :remove_destination => true
  end
  build_dir.rmtree if build_dir.directory?
end

.keywordObject



4
5
6
# File 'lib/cocoapods-binary/podfile_options.rb', line 4

def self.keyword
    :binary
end