Method: Fastlane::LaneList.generate_swift_lanes

Defined in:
fastlane/lib/fastlane/lane_list.rb

.generate_swift_lanes(path) ⇒ Object



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
# File 'fastlane/lib/fastlane/lane_list.rb', line 12

def self.generate_swift_lanes(path)
  return unless (path || '').length > 0
  UI.user_error!("Could not find Fastfile.swift at path '#{path}'") unless File.exist?(path)
  path = File.expand_path(path)
  lane_content = File.read(path)

  current_lane_name = nil
  lanes_by_name = {}

  lane_content.split("\n").reject(&:empty?).each do |line|
    line.strip!
    if line.start_with?("func") && (current_lane_name = self.lane_name_from_swift_line(potential_lane_line: line))
      lanes_by_name[current_lane_name] = Fastlane::Lane.new(platform: nil, name: current_lane_name.to_sym, description: [])
    elsif line.start_with?("desc")
      lane_description = self.desc_entry_for_swift_lane(named: current_lane_name, potential_desc_line: line)
      unless lane_description
        next
      end

      lanes_by_name[current_lane_name].description = [lane_description]
      current_lane_name = nil
    end
  end
  # "" because that will be interpreted as general platform
  # (we don't detect platform right now)
  return { "" => lanes_by_name }
end