Skip to content

Commit

Permalink
Merge pull request #62 from thelvis4/master
Browse files Browse the repository at this point in the history
Use the scheme matching the project name
  • Loading branch information
mpirri committed Feb 29, 2016
2 parents 70122a2 + 6e4b784 commit 6d576e7
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 8 deletions.
31 changes: 23 additions & 8 deletions lib/fastlane_core/project.rb
Expand Up @@ -80,6 +80,14 @@ def workspace?
self.is_workspace
end

def project_name
if is_workspace
return File.basename(options[:workspace], ".xcworkspace")
else
return File.basename(options[:project], ".xcodeproj")
end
end

# Get all available schemes in an array
def schemes
parsed_info.schemes
Expand Down Expand Up @@ -109,15 +117,16 @@ def select_scheme(preferred_to_include: nil)

if preferred_to_include and preferred.count == 1
options[:scheme] = preferred.last
elsif automated_scheme_selection? && schemes.include?(project_name)
Helper.log.info "Using scheme matching project name (#{project_name}).".yellow
options[:scheme] = project_name
elsif Helper.is_ci?
Helper.log.error "Multiple schemes found but you haven't specified one.".red
Helper.log.error "Since this is a CI, please pass one using the `scheme` option".red
raise "Multiple schemes found".red
else
if Helper.is_ci?
Helper.log.error "Multiple schemes found but you haven't specified one.".red
Helper.log.error "Since this is a CI, please pass one using the `scheme` option".red
raise "Multiple schemes found".red
else
puts "Select Scheme: "
options[:scheme] = choose(*(schemes))
end
puts "Select Scheme: "
options[:scheme] = choose(*(schemes))
end
else
Helper.log.error "Couldn't find any schemes in this project, make sure that the scheme is shared if you are using a workspace".red
Expand Down Expand Up @@ -290,5 +299,11 @@ def parsed_info
end
@parsed_info
end

# If scheme not specified, do we want the scheme
# matching project name?
def automated_scheme_selection?
!!ENV["AUTOMATED_SCHEME_SELECTION"]
end
end
end
4 changes: 4 additions & 0 deletions spec/project_spec.rb
Expand Up @@ -20,6 +20,10 @@
expect(@project.is_workspace).to eq(false)
end

it "#project_name" do
expect(@project.project_name).to eq("Example")
end

it "#schemes returns all available schemes" do
expect(@project.schemes).to eq(["Example"])
end
Expand Down

0 comments on commit 6d576e7

Please sign in to comment.