Class: Fastlane::Actions::GetTargetTypeAction

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

Documentation collapse

Class Method Summary collapse

Class Method Details

.authorsObject



86
87
88
89
# File 'lib/fastlane/plugin/ci_apps/actions/get_target_type.rb', line 86

def self.authors
  # So no one will ever forget your contribution to fastlane :) You are awesome btw!
  ["Your GitHub/Twitter Name"]
end

.available_optionsObject



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/fastlane/plugin/ci_apps/actions/get_target_type.rb', line 54

def self.available_options
  # Define all options your action supports. 
  
  # Below a few examples
  [
    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",
                                conflicting_options: [:scheme],
                                description: "Specify a specific target if you have multiple per project, optional")
  ]
end

.descriptionObject



44
45
46
# File 'lib/fastlane/plugin/ci_apps/actions/get_target_type.rb', line 44

def self.description
  "A short description with <= 80 characters of what this action does"
end

.detailsObject



48
49
50
51
52
# File 'lib/fastlane/plugin/ci_apps/actions/get_target_type.rb', line 48

def self.details
  # Optional:
  # this is your chance to provide a more detailed description of this action
  "You can use this action to do cool things..."
end

.find_target(params) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/fastlane/plugin/ci_apps/actions/get_target_type.rb', line 24

def self.find_target(params)
  project = Xcodeproj::Project.open(params[:xcodeproj])
  if params[:target]
    target = project.targets.detect { |t| t.name == params[:target] }
    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?
    target
  end
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/fastlane/plugin/ci_apps/actions/get_target_type.rb', line 91

def self.is_supported?(platform)
  # you can do things like
  # 
  #  true
  # 
  #  platform == :ios
  # 
  #  [:ios, :mac].include?(platform)
  # 

  platform == :ios
end

.outputObject



74
75
76
77
78
79
80
# File 'lib/fastlane/plugin/ci_apps/actions/get_target_type.rb', line 74

def self.output
  # Define the shared values you are going to provide
  # Example
  [
    ['GET_TARGET_TYPE_CUSTOM_VALUE', 'A description of what this value contains']
  ]
end

.return_valueObject



82
83
84
# File 'lib/fastlane/plugin/ci_apps/actions/get_target_type.rb', line 82

def self.return_value
  # If your method provides a return value, you can describe here what it does
end

.run(params) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/fastlane/plugin/ci_apps/actions/get_target_type.rb', line 10

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

  target = find_target(params)
  targetType = target.product_type
  targetType
end