Skip to content

Commit

Permalink
Improve target variable definition
Browse files Browse the repository at this point in the history
BEfore that a blanc .ccios file was causing issue because template was not defined
  • Loading branch information
alexandre-pod committed Dec 6, 2024
1 parent 0962071 commit 5db2539
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 7 deletions.
5 changes: 1 addition & 4 deletions lib/ccios/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,7 @@ def self.default
end

def self.default_config_hash
{
# A blank target by default will use the first one found
"variables" => { "target" => "" }
}
{}
end

def initialize(config_hash, source_path = nil)
Expand Down
4 changes: 2 additions & 2 deletions lib/ccios/file_template_definition.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def validate(parser, project, context, template_definition, config)
raise "Base path \"#{base_path}\" is missing" if base_group.nil?

target_name = merged_variables["target"]
if target_name.is_a?(String)
if target_name.is_a?(String) || target_name.nil?
target = parser.target_for(project, target_name)
raise "Unable to find target \"#{target_name}\"" if target.nil?
elsif target_name.is_a?(Array)
Expand Down Expand Up @@ -77,7 +77,7 @@ def generate(parser, project, context, template_definition, config)
target_name = merged_variables["target"]

targets = []
if target_name.is_a?(String)
if target_name.is_a?(String) || target_name.nil?
targets = [parser.target_for(project, target_name)]
elsif target_name.is_a?(Array)
targets = target_name.map { |name| parser.target_for(project, name) }
Expand Down
2 changes: 1 addition & 1 deletion lib/ccios/pbxproj_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def project_for(path)
end

def target_for(project, target_name)
if target_name.blank?
if target_name.blank? || target_name.nil?
project.targets.find { |t| t.product_type == "com.apple.product-type.application" }
else
project.targets.find { |t| t.name == target_name }
Expand Down

0 comments on commit 5db2539

Please sign in to comment.