Sha256: ce4747bfa1590fca409eacd0b6a96f4f8b8f628628d747df3d3902219c34f585

Contents?: true

Size: 1.67 KB

Versions: 14

Compression:

Stored size: 1.67 KB

Contents

require 'plist'

module Fastlane
  module Actions
    class UpdateUrlSchemesAction < Action
      def self.run(params)
        path = params[:path]
        url_schemes = params[:url_schemes]

        hash = Plist.parse_xml(path)
        hash['CFBundleURLTypes'].first['CFBundleURLSchemes'] = url_schemes
        File.write(path, hash.to_plist)
      end

      def self.description
        'Updates the URL schemes in the given Info.plist'
      end

      def self.available_options
        [
          FastlaneCore::ConfigItem.new(
            key: :path,
            env_name: 'FL_UPDATE_URL_SCHEMES_PATH',
            description: 'The Plist file\'s path',
            is_string: true,
            optional: false,
            verify_block: proc do |path|
              UI.user_error!("Could not find plist at path '#{path}'") unless File.exist?(path)
            end
          ),

          FastlaneCore::ConfigItem.new(
            key: :url_schemes,
            env_name: "FL_UPDATE_URL_SCHEMES_SCHEMES",
            description: 'The new URL schemes',
            is_string: false,
            optional: false,
            verify_block: proc do |url_schemes|
              string = "The URL schemes must be an array of strings, got '#{url_schemes}'.".red
              raise string unless url_schemes.kind_of?(Array)

              url_schemes.each do |url_scheme|
                raise string unless url_scheme.kind_of?(String)
              end
            end
          )
        ]
      end

      def self.output
        []
      end

      def self.authors
        ['kmikael']
      end

      def self.is_supported?(platform)
        [:ios, :mac].include? platform
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
fastlane-1.89.0 lib/fastlane/actions/update_url_schemes.rb
fastlane-1.88.0 lib/fastlane/actions/update_url_schemes.rb
fastlane-1.87.1 lib/fastlane/actions/update_url_schemes.rb
fastlane-1.87.0 lib/fastlane/actions/update_url_schemes.rb
fastlane-1.86.1 lib/fastlane/actions/update_url_schemes.rb
fastlane-1.86.0 lib/fastlane/actions/update_url_schemes.rb
fastlane-1.85.0 lib/fastlane/actions/update_url_schemes.rb
fastlane-1.84.0 lib/fastlane/actions/update_url_schemes.rb
fastlane-1.83.0 lib/fastlane/actions/update_url_schemes.rb
fastlane-1.82.0 lib/fastlane/actions/update_url_schemes.rb
fastlane-1.81.0 lib/fastlane/actions/update_url_schemes.rb
fastlane-1.80.0 lib/fastlane/actions/update_url_schemes.rb
fastlane-1.70.0 lib/fastlane/actions/update_url_schemes.rb
fastlane-1.69.0 lib/fastlane/actions/update_url_schemes.rb