Class: Fastlane::Actions::GetInfoPlistPathAction

Inherits:
Action
  • Object
show all
Defined in:
lib/fastlane/plugin/versioning/actions/get_info_plist_path.rb

Documentation collapse

Class Method Summary collapse

Class Method Details

.authors ⇒ Object



77
78
79
# File 'lib/fastlane/plugin/versioning/actions/get_info_plist_path.rb', line 77

def self.authors
  ["SiarheiFedartsou"]
end

.available_options ⇒ Object



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/fastlane/plugin/versioning/actions/get_info_plist_path.rb', line 56

def self.available_options
  [
    FastlaneCore::ConfigItem.new(key: :xcodeproj,
                       env_name: "FL_INFO_PLIST_PROJECT",
                       description: "optional, you must specify the path to your main Xcode project if it is not in the project root directory or if you have multiple *.xcodeproj's in the root directory",
                       optional: true,
                       verify_block: proc do |value|
                         UI.user_error!("Please pass the path to the project, not the workspace") if value.end_with? ".xcworkspace"
                         UI.user_error!("Could not find Xcode project at path '#{File.expand_path(value)}'") if !File.exist?(value) and !Helper.is_test?
                       end),
    FastlaneCore::ConfigItem.new(key: :target,
                       env_name: "FL_INFO_PLIST_TARGET",
                       optional: true,
                       description: "Specify a specific target if you have multiple per project, optional"),
    FastlaneCore::ConfigItem.new(key: :build_configuration_name,
                       optional: true,
                       description: "Specify a specific build configuration if you have different Info.plist build settings for each configuration")

  ]
end

.description ⇒ Object



46
47
48
# File 'lib/fastlane/plugin/versioning/actions/get_info_plist_path.rb', line 46

def self.description
  "Get the version number of your project"
end

.details ⇒ Object



50
51
52
53
54
# File 'lib/fastlane/plugin/versioning/actions/get_info_plist_path.rb', line 50

def self.details
  [
    "This action will return path to Info.plist for specific target in your project."
  ].join(' ')
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


81
82
83
# File 'lib/fastlane/plugin/versioning/actions/get_info_plist_path.rb', line 81

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

.run(params) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/fastlane/plugin/versioning/actions/get_info_plist_path.rb', line 6

def self.run(params)
  unless params[:xcodeproj]
    if Helper.test?
      params[:xcodeproj] = "/tmp/fastlane/tests/fastlane/bundle.xcodeproj"
    else
      params[:xcodeproj] = Dir["*.xcodeproj"][0] unless params[:xcodeproj]
    end
  end

  project = Xcodeproj::Project.open(params[:xcodeproj])

  if params[:target]
    target = project.targets.detect { |t| t.name == params[:target]}
  else
    # firstly we are trying to find modern application target
    target = project.targets.detect do |t|
      t.kind_of?(Xcodeproj::Project::Object::PBXNativeTarget) &&
      t.product_type == 'com.apple.product-type.application'
    end
    target = project.targets[0] if target.nil?
  end

  if params[:build_configuration_name]
    build_settings = target.build_settings(params[:build_configuration_name])
    plist = build_settings['INFOPLIST_FILE']
  else
    begin
      plist = target.common_resolved_build_setting('INFOPLIST_FILE')
    rescue
      UI.user_error! 'Cannot resolve Info.plist build setting. Maybe you should specify :build_configuration_name?'
    end
  end

  plist.gsub('$(SRCROOT)', project.path.parent.to_path)
end