Class: Pod::Prebuild

Inherits:
Object
  • Object
show all
Defined in:
lib/cocoapods-binary-matchup/helper/passer.rb,
lib/cocoapods-binary-matchup/rome/build_framework.rb,
lib/cocoapods-binary-matchup/helper/target_checker.rb,
lib/cocoapods-binary-matchup/helper/podfile_options.rb

Defined Under Namespace

Classes: Passer

Class Method Summary collapse

Class Method Details

.build(sandbox_root_path, target, output_path, bitcode_enabled = false, custom_build_options = [], custom_build_options_simulator = []) ⇒ Object

Build the frameworks with sandbox and targets

Parameters:

  • sandbox_root_path (String)

    The sandbox root path where the targets project place

    [PodTarget] target The pod targets to build

    [Pathname] output_path output path for generated frameworks

Raises:

  • (Pod::Informative)


355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
# File 'lib/cocoapods-binary-matchup/rome/build_framework.rb', line 355

def self.build(sandbox_root_path, target, output_path, bitcode_enabled = false, custom_build_options=[], custom_build_options_simulator=[])

  return if target.nil?

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

  # -- build the framework
  case target.platform.name
  when :ios then build_for_iosish_platform(sandbox, build_dir, output_path, target, 'iphoneos', 'iphonesimulator', bitcode_enabled, custom_build_options, custom_build_options_simulator)
  when :osx then xcodebuild(sandbox, target.label, 'macosx', nil, custom_build_options)
  # when :tvos then build_for_iosish_platform(sandbox, build_dir, target, 'appletvos', 'appletvsimulator')
  when :watchos then build_for_iosish_platform(sandbox, build_dir, output_path, target, 'watchos', 'watchsimulator', true, custom_build_options, custom_build_options_simulator)
  else raise "Unsupported platform for '#{target.name}': '#{target.platform.name}'" end

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

  # # --- copy the vendored libraries and framework
  # frameworks = build_dir.children.select{ |path| File.extname(path) == ".framework" }
  # Pod::UI.puts "Built #{frameworks.count} #{'frameworks'.pluralize(frameworks.count)}"

  # pod_target = 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

  # frameworks.uniq!

  # 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

.build_dir(sandbox_root) ⇒ Object



399
400
401
402
# File 'lib/cocoapods-binary-matchup/rome/build_framework.rb', line 399

def self.build_dir(sandbox_root)
  # don't know why xcode chose this folder
  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>)


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
41
42
43
44
45
# File 'lib/cocoapods-binary-matchup/helper/target_checker.rb', line 8

def self.check_one_pod_should_have_only_one_target(prebuilt_targets)

  targets_have_different_platforms = prebuilt_targets.select {|t| t.pod_name != t.name }

  if targets_have_different_platforms.count > 0
    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-matchup.

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
end

.keywordObject



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

def self.keyword
    :binary
end

.remove_build_dir(sandbox_root) ⇒ Object



392
393
394
395
# File 'lib/cocoapods-binary-matchup/rome/build_framework.rb', line 392

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