Class: HighFive::Thor::Tasks::IosTasks

Inherits:
HighFive::Thor::Task show all
Includes:
ImageHelper, IosHelper, Thor::Actions
Defined in:
lib/high_five/thor/tasks/ios_tasks.rb

Instance Method Summary collapse

Methods included from ImageHelper

#replace_image

Methods included from IosHelper

#info_plist_path, #ios_icon_sizes, #ios_path, #xcodeproj_path

Methods inherited from HighFive::Thor::Task

banner, #initialize

Constructor Details

This class inherits a constructor from HighFive::Thor::Task

Instance Method Details

#set_icon(path) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/high_five/thor/tasks/ios_tasks.rb', line 38

def set_icon(path)
  icon_files = plist['CFBundleIcons']["CFBundlePrimaryIcon"]["CFBundleIconFiles"]
  icon_files += [ plist['CFBundleIconFile'] ]
  icon_files += plist['CFBundleIcons~ipad']["CFBundlePrimaryIcon"]["CFBundleIconFiles"]
  icon_files.each do |icon_entry|
    icon_file_name = icon_entry
    unless icon_entry.end_with? ".png"
      icon_file_name += ".png"
    end

    # look in a directory named after the target first, if it's present
    # This helps with multi-target apps
    old_icon_path = Dir[File.join(ios_path, "#{target}/**/#{icon_file_name}")].first 
    old_icon_path = Dir[File.join(ios_path, "**/#{icon_file_name}")].first if old_icon_path.nil?

    if old_icon_path.nil?
      puts "Skipping #{icon_entry} because the file is missing.  This will cause problems with app store submission"
      next
    end
    print "Replacing #{old_icon_path}..."
    old_image = ChunkyPNG::Image.from_file(old_icon_path)
    puts "#{old_image.width}x#{old_image.height}"
    replace_image(old_icon_path, path)
    
  end
end

#set_versionObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/high_five/thor/tasks/ios_tasks.rb', line 19

def set_version
  if (options[:version])
    puts "Changing version from #{plist["CFBundleShortVersionString"]} => #{options[:version]}"
    plist["CFBundleShortVersionString"] = options[:version]
  end

  if (options[:build_number])
    puts "Changind build number from #{plist["CFBundleVersion"]} => #{options[:build_number]}"
    plist["CFBundleVersion"] = options[:build_number]
  end
  File.open(plist_path, 'w') do |f|
    f.write(Plist::Emit.dump(plist))
  end
  puts "Wrote Info.plist succesfully"
end