Top Level Namespace

Defined Under Namespace

Modules: CocoapodsPrecompile, Pod

Constant Summary collapse

CONFIGURATION =
"Release"
PLATFORMS =
{ 'iphonesimulator' => 'iOS',
'appletvsimulator' => 'tvOS',
'watchsimulator' => 'watchOS' }

Instance Method Summary collapse

Instance Method Details

#build_for_iosish_platform(sandbox, build_dir, output_path, target, device, simulator, bitcode_enabled, simulator_default_arch) ⇒ Object

Build specific target to framework file

@param [PodTarget] target
       a specific pod target


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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/cocoapods-binary/rome/build_framework.rb', line 12

def build_for_iosish_platform(sandbox, 
                              build_dir, 
                              output_path,
                              target, 
                              device, 
                              simulator,
                              bitcode_enabled,
                              simulator_default_arch)

  deployment_target = target.platform.deployment_target.to_s
  
  target_label = target.label # name with platform if it's used in multiple platforms
  Pod::UI.puts "Prebuilding #{target_label}..."
  
  other_options = [] 
  if bitcode_enabled
    other_options += ['OTHER_CFLAGS="-fembed-bitcode"']
  end
  xcodebuild(sandbox, target_label, device, deployment_target, other_options)
  xcodebuild(sandbox, target_label, simulator, deployment_target, other_options + ["ARCHS=#{simulator_default_arch}",'ONLY_ACTIVE_ARCH=NO'])

  # paths
  target_name = target.name # equals target.label, like "AFNeworking-iOS" when AFNetworking is used in multiple platforms.
  module_name = target.product_module_name
  device_framwork_path = "#{build_dir}/#{CONFIGURATION}-#{device}/#{target_name}/#{module_name}.framework"
  simulator_framwork_path = "#{build_dir}/#{CONFIGURATION}-#{simulator}/#{target_name}/#{module_name}.framework"

  device_binary = device_framwork_path + "/#{module_name}"
  simulator_binary = simulator_framwork_path + "/#{module_name}"
  return unless File.file?(device_binary) && File.file?(simulator_binary)
  
  # the device_lib path is the final output file path
  # combine the bianries
  tmp_lipoed_binary_path = "#{build_dir}/#{target_name}"
  lipo_log = `lipo -create -output #{tmp_lipoed_binary_path} #{device_binary} #{simulator_binary}`
  puts lipo_log unless File.exist?(tmp_lipoed_binary_path)
  FileUtils.mv tmp_lipoed_binary_path, device_binary, :force => true
  
  # collect the swiftmodule file for various archs.
  device_swiftmodule_path = device_framwork_path + "/Modules/#{module_name}.swiftmodule"
  simulator_swiftmodule_path = simulator_framwork_path + "/Modules/#{module_name}.swiftmodule"
  if File.exist?(device_swiftmodule_path)
    FileUtils.cp_r simulator_swiftmodule_path + "/.", device_swiftmodule_path
  end

  # output
  output_path.mkpath unless output_path.exist?
  FileUtils.mv device_framwork_path, output_path, :force => true

end

#class_attr_accessor(symbol) ⇒ Object

attr_accessor for class variable. usage:

```
class Pod
    class_attr_accessor :is_prebuild_stage
end
```


10
11
12
# File 'lib/cocoapods-binary/tool/tool.rb', line 10

def class_attr_accessor(symbol)
    self.class.send(:attr_accessor, symbol)
end

#xcodebuild(sandbox, target, sdk = 'macosx', deployment_target = nil, other_options = []) ⇒ Object



63
64
65
66
67
68
69
# File 'lib/cocoapods-binary/rome/build_framework.rb', line 63

def xcodebuild(sandbox, target, sdk='macosx', deployment_target=nil, other_options=[])
  args = %W(-project #{sandbox.project_path.realdirpath} -scheme #{target} -configuration #{CONFIGURATION} -sdk #{sdk} )
  platform = PLATFORMS[sdk]
  args += Fourflusher::SimControl.new.destination(:oldest, platform, deployment_target) unless platform.nil?
  args += other_options
  Pod::Executable.execute_command 'xcodebuild', args, true
end