Skip to content

Commit 0c84f25

Browse files
authored
Fix build settings overwrite issue. (#282)
1 parent 446a88c commit 0c84f25

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

xcodebuild/show_build_settings.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,9 @@ func (c ShowBuildSettingsCommandModel) PrintableCmd() string {
9696
return command.PrintableCommandArgs(false, cmdSlice)
9797
}
9898

99+
// parseBuildSettings parses xcodebuild -showBuildSettings output into a map of build settings.
100+
// When using multi-target schemes, the output may contain multiple entries for the same key.
101+
// In this case, the first occurrence of each key is used, which corresponds to the main target.
99102
func parseBuildSettings(out string) (serialized.Object, error) {
100103
settings := serialized.Object{}
101104

@@ -122,7 +125,10 @@ func parseBuildSettings(out string) (serialized.Object, error) {
122125
value := strings.TrimSpace(strings.Join(split[1:], "="))
123126
value = strings.Trim(value, `"`)
124127

125-
settings[key] = value
128+
// Use the first occurrence of each key (the main target in case of multi-target schemes)
129+
if _, exists := settings[key]; !exists {
130+
settings[key] = value
131+
}
126132
}
127133

128134
buffer.Reset()

0 commit comments

Comments
 (0)