Class: CBin::BuildAll::Builder

Inherits:
Object
  • Object
show all
Includes:
Pod
Defined in:
lib/cocoapods-mtxx-bin/helpers/buildAll/builder.rb

Instance Method Summary collapse

Methods included from Pod

match_version?

Constructor Details

#initialize(pod_target, checkout_sources, skip_simulator = false, configuration = 'Debug') ⇒ Builder

Returns a new instance of Builder.

[View source]

7
8
9
10
11
12
13
14
# File 'lib/cocoapods-mtxx-bin/helpers/buildAll/builder.rb', line 7

def initialize(pod_target, checkout_sources, skip_simulator = false, configuration = 'Debug')
  @pod_target = pod_target
  @checkout_sources = checkout_sources
  @skip_simulator = skip_simulator
  @configuration = configuration
  @file_accessors = pod_target.file_accessors unless pod_target.nil?
  @base_dir = "#{Pathname.pwd}/build_pods"
end

Instance Method Details

#buildObject

构建

[View source]

17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/cocoapods-mtxx-bin/helpers/buildAll/builder.rb', line 17

def build
  UI.info "编译`#{@pod_target}`".yellow
  dir = result_product_dir
  FileUtils.rm_rf(dir) if File.exist?(dir)
  # 编译模拟器
  unless @skip_simulator
    result = build_pod_target
    return false unless result
  end
  # 编译真机
  build_pod_target(false)
end

#build_as_framework?Boolean

是否以framework形式构建

Returns:

  • (Boolean)
[View source]

63
64
65
66
# File 'lib/cocoapods-mtxx-bin/helpers/buildAll/builder.rb', line 63

def build_as_framework?
  path = "#{product_dir}/#{iphoneos}/#{@pod_target}/#{@pod_target.framework_name}"
  File.exist?(path)
end

#create_binaryObject

创建binary

[View source]

31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/cocoapods-mtxx-bin/helpers/buildAll/builder.rb', line 31

def create_binary
  UI.info "创建`#{@pod_target.framework_name}`".yellow
  # 如果是framework需要先copy
  if build_as_framework?
    copy_framework
  else
    create_framework_dir
    copy_headers
    copy_headers(false )
    generate_umbrella_header
    generate_module_map
    compile_resources
    if @pod_target.uses_swift?
      copy_iphoneos_swiftmodules
      copy_simulator_swiftmodules unless @skip_simulator
    end
    if @skip_simulator
      device_lib = "#{product_dir}/#{iphoneos}/#{@pod_target}/#{@pod_target.static_library_name}"
      output = "#{result_product_dir}/#{@pod_target.product_module_name}"
      `cp -f #{device_lib} #{output}`
    end
  end
  # 合并真机模拟器
  merge_device_sim unless @skip_simulator
  # 拷贝资源文件
  copy_resources
  # 拷贝 vendored_frameworks 和 vendored_libraries
  copy_vendored_frameworks
  copy_vendored_libraries
end

#headers_dirObject

xxx.framework/Headers

[View source]

74
75
76
# File 'lib/cocoapods-mtxx-bin/helpers/buildAll/builder.rb', line 74

def headers_dir
  "#{result_product_dir}/Headers"
end

#iphoneosObject

[View source]

104
105
106
# File 'lib/cocoapods-mtxx-bin/helpers/buildAll/builder.rb', line 104

def iphoneos
  "#{@configuration}-iphoneos"
end

#iphonesimulatorObject

[View source]

108
109
110
# File 'lib/cocoapods-mtxx-bin/helpers/buildAll/builder.rb', line 108

def iphonesimulator
  "#{@configuration}-iphonesimulator"
end

#modules_dirObject

xxx.framework/Modules

[View source]

69
70
71
# File 'lib/cocoapods-mtxx-bin/helpers/buildAll/builder.rb', line 69

def modules_dir
  "#{result_product_dir}/Modules"
end

#private_headers_dirObject

xxx.framework/PrivateHeaders

[View source]

79
80
81
# File 'lib/cocoapods-mtxx-bin/helpers/buildAll/builder.rb', line 79

def private_headers_dir
  "#{result_product_dir}/PrivateHeaders"
end

#product_dirObject

xxx.framework 所在目录

[View source]

94
95
96
97
# File 'lib/cocoapods-mtxx-bin/helpers/buildAll/builder.rb', line 94

def product_dir
  @product_dir = "#{@base_dir}/#{@pod_target}/Products"
  @product_dir
end

#reject_resource_extObject

需要排除的资源文件后缀

[View source]

113
114
115
# File 'lib/cocoapods-mtxx-bin/helpers/buildAll/builder.rb', line 113

def reject_resource_ext
  %w[.xcdatamodeld .xcdatamodel .xcmappingmodel .xib .storyboard]
end

#resources_dirObject

xxx.framework/resources

[View source]

84
85
86
# File 'lib/cocoapods-mtxx-bin/helpers/buildAll/builder.rb', line 84

def resources_dir
  "#{result_product_dir}/resources"
end

#result_product_dirObject

xxx.framework

[View source]

89
90
91
# File 'lib/cocoapods-mtxx-bin/helpers/buildAll/builder.rb', line 89

def result_product_dir
  "#{product_dir}/#{@pod_target.framework_name}"
end

#temp_dirObject

构建临时产物目录

[View source]

100
101
102
# File 'lib/cocoapods-mtxx-bin/helpers/buildAll/builder.rb', line 100

def temp_dir
  "#{@base_dir}/#{@pod_target}/Temp"
end