Class: HighFive::Thor::Tasks::Ios

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

Instance Method Summary collapse

Methods included from ImageHelper

#generate_ios_splash_screen_image, #generate_splash_screen_image, #replace_image

Methods included from IosHelper

#info_plist_path, #ios_icon_sizes, #ios_path, uuid_from_mobileprovision, #xcodeproj_path

Methods inherited from HighFive::Thor::Task

inherited

Instance Method Details

#generate_splash_screen(path) ⇒ Object



114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
# File 'lib/high_five/thor/tasks/ios.rb', line 114

def generate_splash_screen(path)
  image = ChunkyPNG::Image.from_file(path)

  splashes_to_make = [
    'iphone_portrait_8_retina_hd_5_5',
    'iphone_portrait_8_retina_hd_4_7',
    'iphone_landscape_8_retina_hd_5_5',
    'iphone_portrait_1x',
    'iphone_portrait_2x',
    'iphone_portrait_retina_4',
    'ios-7-iphone_portrait_2x',
    'ios-7-iphone_portrait_retina_4',
    'ipad_portrait_1x',
    'ipad_portrait_2x',
    'ipad_landscape_1x',
    'ipad_landscape_2x',
    'ipad_portrait_without_status_bar_5_6_1x',
    'ipad_portrait_without_status_bar_5_6_2x',
    'ipad_landscape_without_status_bar_5_6_1x',
    'ipad_landscape_without_status_bar_5_6_2x'
  ]

  splashes_to_make.each do |type|
    generate_ios_splash_screen_image(type, ios_path, path, options[:color] || "#ffffff")
  end

  puts "Make sure you assign them in xcode if this is the first time you generated these"
end

#set_icon(path) ⇒ Object



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/high_five/thor/tasks/ios.rb', line 47

def set_icon(path)
  begin
    icon_files = plist['CFBundleIcons']["CFBundlePrimaryIcon"]["CFBundleIconFiles"]
    icon_files += [ plist['CFBundleIconFile'] ]
    icon_files += plist['CFBundleIcons~ipad']["CFBundlePrimaryIcon"]["CFBundleIconFiles"]
  rescue
    icon_files = []
  end
  if icon_files.empty?
    icon_files = Dir.glob("#{ios_path}/**/AppIcon.appiconset/*.png")
  end
  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?
    old_icon_path = Dir[File.join(icon_entry)].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_propertyObject



36
37
38
39
40
41
42
# File 'lib/high_five/thor/tasks/ios.rb', line 36

def set_property
  unless options[:key] && options[:value]
    raise "Need to set key and value options"
  end
  set_plist_property options[:key], options[:value]
  write_plist
end

#set_splash_screen(path) ⇒ Object



83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# File 'lib/high_five/thor/tasks/ios.rb', line 83

def set_splash_screen(path)
  image = ChunkyPNG::Image.from_file(path)

  splashes_to_make = [
    'iphone_portrait_8_retina_hd_5_5',
    'iphone_portrait_8_retina_hd_4_7',
    'iphone_landscape_8_retina_hd_5_5',
    'iphone_portrait_1x',
    'iphone_portrait_2x',
    'iphone_portrait_retina_4',
    'ios-7-iphone_portrait_2x',
    'ios-7-iphone_portrait_retina_4',
    'ipad_portrait_1x',
    'ipad_portrait_2x',
    'ipad_landscape_1x',
    'ipad_landscape_2x',
    'ipad_portrait_without_status_bar_5_6_1x',
    'ipad_portrait_without_status_bar_5_6_2x',
    'ipad_landscape_without_status_bar_5_6_1x',
    'ipad_landscape_without_status_bar_5_6_2x'
  ]

  splashes_to_make.each do |type|
    generate_ios_splash_screen_image(type, ios_path, path, nil, true)
  end

  puts "Make sure you assign them in xcode if this is the first time you generated these"
end

#set_versionObject



18
19
20
21
22
23
24
25
26
27
28
# File 'lib/high_five/thor/tasks/ios.rb', line 18

def set_version
  if options[:version]
    set_plist_property "CFBundleShortVersionString", options[:version]
  end

  if options[:build_number]
    set_plist_property "CFBundleVersion", options[:build_number]
  end

  write_plist
end