Class: Pod::Prebuild

Inherits:
Object
  • Object
show all
Defined in:
lib/cocoapods-binary-cache/pod-binary/helper/build.rb,
lib/cocoapods-binary-cache/pod-binary/helper/target_checker.rb

Class Method Summary collapse

Class Method Details

.build(options) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/cocoapods-binary-cache/pod-binary/helper/build.rb', line 6

def self.build(options)
  target = options[:target]
  return if target.nil?

  Pod::UI.puts "Building target: #{target}...".magenta
  options[:sandbox] = Pod::Sandbox.new(Pathname(options[:sandbox])) unless options[:sandbox].is_a?(Pod::Sandbox)
  options[:build_dir] = build_dir(options[:sandbox].root)

  case target.platform.name
  when :ios, :tvos, :watchos
    XcodebuildCommand.new(options).run
  when :osx
    xcodebuild(
      sandbox: options[:sandbox],
      target: target.label,
      configuration: options[:configuration],
      sdk: "macosx",
      args: options[:args]
    )
  else
    raise "Unsupported platform for '#{target.name}': '#{target.platform.name}'"
  end
  raise "The build directory was not found in the expected location" unless options[:build_dir].directory?
end

.build_dir(sandbox_root) ⇒ Object



36
37
38
# File 'lib/cocoapods-binary-cache/pod-binary/helper/build.rb', line 36

def self.build_dir(sandbox_root)
  sandbox_root.parent + "build"
end

.check_one_pod_should_have_only_one_target(prebuilt_targets) ⇒ Object

Check the targets, for the current limitation of the plugin

Parameters:

  • prebuilt_targets (Array<PodTarget>)

Raises:

  • (Informative)


6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/cocoapods-binary-cache/pod-binary/helper/target_checker.rb', line 6

def self.check_one_pod_should_have_only_one_target(prebuilt_targets)
  targets_have_different_platforms = prebuilt_targets.reject { |t| t.pod_name == t.name }
  return unless targets_have_different_platforms.empty?

  names = targets_have_different_platforms.map(&:pod_name)
  raw_names = targets_have_different_platforms.map(&:name)
  message = "Oops, you came across a limitation of cocoapods-binary.

The plugin requires that one pod should have ONLY ONE target in the 'Pod.xcodeproj'. There are mainly 2 situations \
causing this problem:

1. One pod integrates in 2 or more different platforms' targets. e.g.
```
target 'iphoneApp' do
  pod 'A', :binary => true
end
target 'watchApp' do
  pod 'A'
end
```

2. Use different subspecs in multiple targets. e.g.
```
target 'iphoneApp' do
  pod 'A/core'
  pod 'A/network'
end
target 'iphoneAppTest' do
  pod 'A/core'
end
```

Related pods: #{names}, target names: #{raw_names}"
  raise Informative, message
end

.remove_build_dir(sandbox_root) ⇒ Object



31
32
33
34
# File 'lib/cocoapods-binary-cache/pod-binary/helper/build.rb', line 31

def self.remove_build_dir(sandbox_root)
  path = build_dir(sandbox_root)
  path.rmtree if path.exist?
end