class Fastlane::Actions::AddPrefixSchemaAction
Public Class Methods
available_options()
click to toggle source
# File lib/fastlane/plugin/polidea/actions/add_prefix_schema.rb, line 49 def self.available_options [ FastlaneCore::ConfigItem.new(key: :path, env_name: "", description: "Path where search for Info.plist begins", default_value: File.absolute_path("."), optional: true) ] end
description()
click to toggle source
# File lib/fastlane/plugin/polidea/actions/add_prefix_schema.rb, line 45 def self.description "Add prefix schema for Polidea Store" end
generate_url_scheme()
click to toggle source
# File lib/fastlane/plugin/polidea/actions/add_prefix_schema.rb, line 27 def self.generate_url_scheme Base64.urlsafe_encode64(SecureRandom.hex)[0..11] end
is_supported?(platform)
click to toggle source
# File lib/fastlane/plugin/polidea/actions/add_prefix_schema.rb, line 69 def self.is_supported?(platform) platform == :ios end
modify_plist(info_plist_path, command)
click to toggle source
# File lib/fastlane/plugin/polidea/actions/add_prefix_schema.rb, line 41 def self.modify_plist(info_plist_path, command) system "/usr/libexec/PlistBuddy -c \"#{command}\" \"#{info_plist_path}\"" end
output()
click to toggle source
# File lib/fastlane/plugin/polidea/actions/add_prefix_schema.rb, line 59 def self.output [ ['PREFIX_SCHEMA', 'Prefix schema added to Info.plist'] ] end
run(config)
click to toggle source
# File lib/fastlane/plugin/polidea/actions/add_prefix_schema.rb, line 10 def self.run(config) Fastlane::Polidea.session.action_launched("add_prefix_schema", config) prefix_schema = generate_url_scheme info_plists = Dir.glob(File.join(config[:path], "**/*.plist")) UI.user_error!("There isn't any Info.plist in this directory") if info_plists.empty? info_plists.each do |info_plist| update_plist(info_plist, prefix_schema) end Actions.lane_context[SharedValues::PREFIX_SCHEMA] = prefix_schema Fastlane::Polidea.session.action_completed("add_prefix_schema") prefix_schema end
update_plist(info_plist_path, prefix_schema)
click to toggle source
# File lib/fastlane/plugin/polidea/actions/add_prefix_schema.rb, line 31 def self.update_plist(info_plist_path, prefix_schema) modify_plist(info_plist_path, "Add :CFBundleURLTypes array") modify_plist(info_plist_path, "Add :CFBundleURLTypes:0 dict") modify_plist(info_plist_path, "Add :CFBundleURLTypes:0:CFBundleURLName string 'com.polideastore.\\$(PRODUCT_NAME)'") modify_plist(info_plist_path, "Add :CFBundleURLTypes:0:CFBundleURLSchemes array") modify_plist(info_plist_path, "Add :CFBundleURLTypes:0:CFBundleURLSchemes:0 string '#{prefix_schema}'") modify_plist(info_plist_path, "Save") UI.success("Added custom url scheme: #{prefix_schema} to plist file: #{info_plist_path}") end