Skip to content

Commit

Permalink
Empty error fix (#50)
Browse files Browse the repository at this point in the history
* Fix empty error when configuration not found

* Improve buildConfiguration func error messages
  • Loading branch information
godrei authored Aug 28, 2024
1 parent 590bee6 commit e7dfd87
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions step/step.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,17 +290,29 @@ func buildConfiguration(helper *projectmanager.ProjectHelper, targetName, config
configuration = helper.MainTarget.BuildConfigurationList.DefaultConfigurationName
}

var xcodeprojTarget *xcodeproj.Target
for _, target := range helper.XcProj.Proj.Targets {
if target.Name != targetName {
continue
if target.Name == targetName {
xcodeprojTarget = &target
break
}
}

for _, buildConfig := range target.BuildConfigurationList.BuildConfigurations {
if buildConfig.Name == configuration {
return &buildConfig, nil
}
if xcodeprojTarget == nil {
return nil, fmt.Errorf("target '%s' not found in project: %s", targetName, helper.XcProj.Path)
}

var xcodeprojBuildConfiguration *xcodeproj.BuildConfiguration
for _, buildConfig := range xcodeprojTarget.BuildConfigurationList.BuildConfigurations {
if buildConfig.Name == configuration {
xcodeprojBuildConfiguration = &buildConfig
break
}
}

return nil, fmt.Errorf("")
if xcodeprojBuildConfiguration == nil {
return nil, fmt.Errorf("build configuration '%s' not found for target '%s' in project: %s", configuration, targetName, helper.XcProj.Path)
}

return xcodeprojBuildConfiguration, nil
}

0 comments on commit e7dfd87

Please sign in to comment.