class Fastlane::Actions::ApplyXcode8SrgbWorkaroundAction

Public Class Methods

authors() click to toggle source
# File lib/fastlane/plugin/xcode8_srgb_workaround/actions/apply_xcode8_srgb_workaround_action.rb, line 19
def self.authors
  ["SiarheiFiedartsou"]
end
available_options() click to toggle source
# File lib/fastlane/plugin/xcode8_srgb_workaround/actions/apply_xcode8_srgb_workaround_action.rb, line 23
def self.available_options
  [

    FastlaneCore::ConfigItem.new(key: :subdirectories,
                          description: "List of subdirectories where PNGs and JPEGs must be detected and converted to sRGB",
                          default_value: ['./**'],
                                type: Array)
  ]
end
description() click to toggle source
# File lib/fastlane/plugin/xcode8_srgb_workaround/actions/apply_xcode8_srgb_workaround_action.rb, line 15
def self.description
  "Converts PNGs and JPEGs in your project to sRGB format to avoid crashes when building with Xcode 8 for iOS 8 and earlier deployment target"
end
is_supported?(platform) click to toggle source
# File lib/fastlane/plugin/xcode8_srgb_workaround/actions/apply_xcode8_srgb_workaround_action.rb, line 33
def self.is_supported?(platform)
  [:ios].include?(platform)
end
run(params) click to toggle source
# File lib/fastlane/plugin/xcode8_srgb_workaround/actions/apply_xcode8_srgb_workaround_action.rb, line 4
def self.run(params)
  params[:subdirectories].each do |subdirectory|
    ['png', 'jpg', 'jpeg'].each do |fmt|
      pattern = File.expand_path(subdirectory) + "/*.#{fmt}"
      Dir[pattern].each do |resource_path|
        `sips -m '/System/Library/Colorsync/Profiles/sRGB Profile.icc' '#{resource_path}' --out '#{resource_path}'`
      end
    end
  end
end