module Flappy::ArchiveIpa

Public Instance Methods

archive_ipa(*args, options) click to toggle source
# 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) click to toggle source
# 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