[xcassets] Use actool’s Info.plist output instead of reading JSON.

This commit is contained in:
Eloy Durán
2013-10-11 20:20:30 +02:00
parent 2490d6c0a2
commit 3be82b061b
4 changed files with 53 additions and 80 deletions

View File

@@ -38,6 +38,7 @@ module Motion; module Project;
@interface_orientations = [:portrait, :landscape_left, :landscape_right]
@background_modes = []
@status_bar_style = :default
@icons = []
@prerendered_icon = false
@manifest_assets = []
end
@@ -56,39 +57,6 @@ module Motion; module Project;
end
end
def icons
@icons ||= app_icons_from_asset_bundle
end
def app_icons_from_asset_bundle
unless @app_icons_from_asset_bundle
@app_icons_from_asset_bundle = []
if app_icon_set = app_icons_asset_bundle
begin
require 'rubygems'
require 'json'
rescue LoadError
App.fail "Using application icons from Xcode asset catalogs " \
"requires the `json' gem to be installed. You can do " \
"so by typing `[sudo] gem install json' in your " \
"terminal or by adding `gem \"json\"' to your Gemfile."
end
app_icon_filename = File.basename(app_icon_set, File.extname(app_icon_set))
images = JSON.parse(File.read(File.join(app_icon_set, 'Contents.json')))['images']
images.each do |image|
if image_src = image['filename']
image_src = File.join(app_icon_set, image_src)
if File.exist?(image_src)
@app_icons_from_asset_bundle << "#{app_icon_filename}#{image['size']}@#{image['scale']}.png"
end
end
end
end
end
@app_icons_from_asset_bundle
end
def validate
# icons
if !(icons.is_a?(Array) and icons.all? { |x| x.is_a?(String) })

View File

@@ -34,6 +34,7 @@ module Motion; module Project;
def initialize(project_dir, build_mode)
super
@icon = ''
@copyright = "Copyright © #{Time.now.year} #{`whoami`.strip}. All rights reserved."
@category = 'utilities'
@frameworks = ['AppKit', 'Foundation', 'CoreGraphics']
@@ -67,16 +68,6 @@ module Motion; module Project;
archs
end
def icon
@icon ||= begin
if app_icon_set = app_icons_asset_bundle
File.basename(app_icon_set, File.extname(app_icon_set)) << '.icns'
else
''
end
end
end
def locate_compiler(platform, *execs)
execs.each do |exec|
cc = File.join('/usr/bin', exec)