Class: XcodeBuilder::Archiver

Inherits:
Object
  • Object
show all
Defined in:
lib/bean/xcodebuild.rb

Class Method Summary collapse

Class Method Details

.archive(config) ⇒ Object



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
# File 'lib/bean/xcodebuild.rb', line 8

def self.archive(config)
  
  workspace = config.workspace
  scheme = config.scheme
  export_path = config.export_path
  tmp_dir = Workspace::TMP_DIR
  Dir.mkdir(tmp_dir) unless Dir.exist?(tmp_dir)

  # The archivePath is /your/project/root/.Tmp/scheme.xcarchive
  archive_path = File.expand_path("#{scheme}.xcarchive", tmp_dir)
  archive_command = "xcodebuild -workspace #{workspace} -scheme #{scheme} clean archive -archivePath #{archive_path}"
 
  begin_time = Time.now
 
  # puts archive_command.red
  return Workspace.clear unless system archive_command

  # If the ExportOptionsPlist does not exist, just return.
  return unless export_option_plist = config.export_options_plist

  # Print the config
  puts config

  export_command = "xcodebuild -exportArchive -archivePath #{archive_path} -exportPath #{export_path} -exportOptionsPlist #{export_option_plist}"
  # puts export_command.red
  return Workspace.clear unless system export_command

  Workspace.clear
  duration = (Time.now - begin_time) / 60
  puts "🎉🎉🎉 Done. It takes you #{duration.to_i.to_s.yellow} min."
end