为了给出一些背景信息,我目前正在使用名为badge的程序将图标叠加层应用于我的应用图标。在我的计算机上本地工作很棒,但是当我在集成之前在xcode bot中运行命令徽章时,我收到以下错误:
Install ImageMagick and start your lane again!
我已经在_xcsbuildd(Xcode Server)用户上多次运行brew update && brew install imagemagick
命令来安装ImageMagick,但我仍然收到错误消息。检查runner.rb
目录下的/Library/Ruby/Gems/2.0.0/gems/badge-0.7.1/lib/badge
文件,我找到了抛出异常的代码。我有一些未解决的问题,希望能给我下一个调试数据点。
1。)文件系统中需要require 'fastimage' require 'timeout' require 'mini_magick'
指向哪里?有没有办法在调用时回显该位置,以便我可以确认它在正确的目录中?
2。)看起来runner.rb有一个名为check_imagemagick!
的方法来判断是否安装了imagemagick如果我做了一个有根据的猜测。有人可以解释这个逻辑在做什么吗?
return if `which convert`.include?('convert')
return if `which gm`.include?('gm')
这是来自runner.rb文件的完整代码:
require 'fastimage'
require 'timeout'
require 'mini_magick'
module Badge
class Runner
@@retry_count = Badge.shield_io_retries
def run(path, options)
check_imagemagick!
glob = "/**/*.appiconset/*.{png,PNG}"
glob = options[:glob] if options[:glob]
UI.message "FP:" + glob
UI.message "P:" + path
app_icons = Dir.glob("#{path}#{glob}")
UI.verbose "Verbose active...".blue
UI.verbose "Parameters: #{options.inspect}".blue
alpha_channel = false
if options[:alpha_channel]
alpha_channel = true
end
if app_icons.count > 0
UI.message "Start adding badges...".green
shield = nil
response_error = false
begin
timeout = Badge.shield_io_timeout
timeout = options[:shield_io_timeout] if options[:shield_io_timeout]
Timeout.timeout(timeout.to_i) do
shield = load_shield(options[:shield]) if options[:shield]
end
rescue Timeout::Error
UI.error "Error loading image from shield.io timeout reached. Skipping Shield. Use --verbose for more info".red
rescue OpenURI::HTTPError => error
response = error.io
UI.error "Error loading image from shield.io response Error. Skipping Shield. Use --verbose for more info".red
UI.error response.status if $verbose
response_error = true
end
if @@retry_count <= 0
UI.error "Cannot load image from shield.io skipping it...".red
elsif response_error
UI.message "Waiting for #{timeout.to_i}s and retry to load image from shield.io tries remaining: #{@@retry_count}".red
sleep timeout.to_i
@@retry_count -= 1
return run(path, options)
end
icon_changed = false
app_icons.each do |full_path|
icon_path = Pathname.new(full_path)
icon = MiniMagick::Image.new(full_path)
result = MiniMagick::Image.new(full_path)
if !options[:no_badge]
result = add_badge(options[:custom], options[:dark], icon, options[:alpha], alpha_channel, options[:badge_gravity])
icon_changed = true
end
if shield
result = add_shield(icon, result, shield, alpha_channel, options[:shield_gravity], options[:shield_no_resize])
icon_changed = true
end
if icon_changed
result.format "png"
result.write full_path
end
end
if icon_changed
UI.message "Badged \\o/!".green
else
UI.message "Did nothing... Enable --verbose for more info.".red
end
else
UI.error "Could not find any app icons...".red
end
end
def add_shield(icon, result, shield, alpha_channel, shield_gravity, shield_no_resize)
UI.message "'#{icon.path}'"
UI.verbose "Adding shield.io image ontop of icon".blue
current_shield = MiniMagick::Image.open(shield.path)
if icon.width > current_shield.width && !shield_no_resize
current_shield.resize "#{icon.width}x#{icon.height}<"
else
current_shield.resize "#{icon.width}x#{icon.height}>"
end
result = composite(result, current_shield, alpha_channel, shield_gravity || "north")
end
def load_shield(shield_string)
url = Badge.shield_base_url + Badge.shield_path + shield_string + ".png"
file_name = shield_string + ".png"
UI.verbose "Trying to load image from shield.io. Timeout: #{Badge.shield_io_timeout}s".blue
UI.verbose "URL: #{url}".blue
shield = Tempfile.new(file_name).tap do |file|
file.binmode
file.write(open(url).read)
file.close
end
end
def check_imagemagick!
return if `which convert`.include?('convert')
return if `which gm`.include?('gm')
UI.error("You have to install ImageMagick or GraphicsMagick to use `badge`")
UI.error("")
UI.error("Install it using (ImageMagick):")
UI.command("brew update && brew install imagemagick")
UI.error("")
UI.error("Install it using (GraphicsMagick):")
UI.command("brew update && brew install graphicsmagick")
UI.error("")
UI.error("If you don't have homebrew, visit http://brew.sh")
UI.user_error!("Install ImageMagick and start your lane again!")
end
def add_badge(custom_badge, dark_badge, icon, alpha_badge, alpha_channel, badge_gravity)
UI.message "'#{icon.path}'"
UI.verbose "Adding badge image ontop of icon".blue
if custom_badge && File.exist?(custom_badge) # check if custom image is provided
badge = MiniMagick::Image.open(custom_badge)
else
if alpha_badge
badge = MiniMagick::Image.open(dark_badge ? Badge.alpha_dark_badge : Badge.alpha_light_badge)
else
badge = MiniMagick::Image.open(dark_badge ? Badge.beta_dark_badge : Badge.beta_light_badge)
end
end
badge.resize "#{icon.width}x#{icon.height}"
result = composite(icon, badge, alpha_channel, badge_gravity || "SouthEast")
end
def composite(image, overlay, alpha_channel, gravity)
image.composite(overlay, 'png') do |c|
c.compose "Over"
c.alpha 'On' unless !alpha_channel
c.gravity gravity
end
end
end
end
我感谢任何帮助。希望我很清楚。在此期间,我将重点介绍Ruby基础知识。
答案 0 :(得分:0)
我没有XCode主人,但听起来你没有正确配置你的XCode服务器或机器人。
which convert
应返回转换&#39;的路径。
是二元的,也是如此which gm
尝试在XCode服务器上运行这些命令,看看你得到了什么。
只是猜测,但您可能需要将这些二进制文件的路径添加到机器人的环境变量中。