Module: Flappy::ArchiveIpa

Included in:
Util::ClassMethods
Defined in:
lib/flappy/util/archive_ipa.rb

Instance Method Summary collapse

Instance Method Details

#archive_ipa(*args, options) ⇒ Object



5
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
41
# File 'lib/flappy/util/archive_ipa.rb', line 5

def archive_ipa(*args, options)

  build_dir = Dir.pwd
  ipa_dir = ''

  if args.count == 2
    build_dir = args.first.to_s
    ipa_dir = args.last.to_s
  elsif args.count == 1
    build_dir = args.first.to_s
  end

  check_condition(build_dir, 'build dir can not be empty!')
  build_dir = File.expand_path(build_dir) unless build_dir.blank?

  unless ipa_dir.blank?
    ipa_path = File.join(ipa_dir, Time.now.strftime('%Y%m%d%H%M%S') + '.ipa')
  else
    ipa_path = File.join(build_dir, Time.now.strftime('%Y%m%d%H%M%S') + '.ipa')
  end

  puts "build_dir: #{build_dir}\nipa_path: #{ipa_path}"

  xcrun_cmd = archive_ipa_with_path(build_dir, ipa_path)

  puts '>>>>>>>>>>>>>>>>>>>>>>>>>>>> Archiving......'
  puts "archive cmd: #{xcrun_cmd}"

  system(xcrun_cmd) unless xcrun_cmd.blank?

  if $?.to_i != 0
    puts '>>>>>>>>>>>>>>>>>>>>>>>>>>>> Archive failed'
    exit 1
  else
    puts '>>>>>>>>>>>>>>>>>>>>>>>>>>>> Archive succeed'
  end
end

#archive_ipa_with_path(build_dir, ipa_path) ⇒ Object



43
44
45
46
47
48
49
50
51
52
53
# File 'lib/flappy/util/archive_ipa.rb', line 43

def archive_ipa_with_path(build_dir, ipa_path)
  check_condition(build_dir, 'build dir is empty!')
  check_condition(ipa_path, 'ipa_path dir is empty!')

  apps = Dir["#{build_dir}/**/*.app"].sort_by(&:size)

  log_iOS("Found .app in build dir: #{apps}")
  check_no_output_app(apps)

  xcrun_cmd = "xcrun --sdk iphoneos PackageApplication -v #{apps.join(' ')} -o #{ipa_path}"
end