Skip to content
This repository was archived by the owner on Feb 26, 2026. It is now read-only.

Commit 7feb8e4

Browse files
committed
Update for strongly typed build settings mapping
1 parent 5552e99 commit 7feb8e4

1 file changed

Lines changed: 5 additions & 23 deletions

File tree

Sources/XcodeGraphMapper/Mappers/Settings/XCConfigurationMapper.swift

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -84,35 +84,17 @@ final class XCConfigurationMapper: SettingsMapping {
8484
/// - Parameter buildSettings: A dictionary of raw build settings.
8585
/// - Returns: A `SettingsDictionary` containing `SettingValue`-typed settings.
8686
/// - Throws: If a setting value cannot be mapped (this is typically non-fatal; most values can be stringified).
87-
func mapBuildSettings(_ buildSettings: [String: Any]) throws -> SettingsDictionary {
87+
func mapBuildSettings(_ buildSettings: [String: BuildSetting]) throws -> SettingsDictionary {
8888
var settingsDict = SettingsDictionary()
8989
for (key, value) in buildSettings {
90-
settingsDict[key] = try mapSettingValue(value)
90+
settingsDict[key] = switch value {
91+
case let .string(string): .string(string)
92+
case let .array(array): .array(array)
93+
}
9194
}
9295
return settingsDict
9396
}
9497

95-
/// Maps a single raw setting value into a `SettingValue`.
96-
///
97-
/// - If the value is a `String`, it becomes a `SettingValue.string`.
98-
/// - If the value is an `Array`, each element is converted to a string if possible, resulting in `SettingValue.array`.
99-
/// - Otherwise, the value is stringified using `String(describing:)` and returned as `SettingValue.string`.
100-
///
101-
/// - Parameter value: A raw setting value from the build settings dictionary.
102-
/// - Returns: A `SettingValue` representing the processed setting.
103-
private func mapSettingValue(_ value: Any) throws -> SettingValue {
104-
if let stringValue = value as? String {
105-
return .string(stringValue)
106-
} else if let arrayValue = value as? [Any] {
107-
let stringArray = arrayValue.compactMap { $0 as? String }
108-
return .array(stringArray)
109-
} else {
110-
// Fallback: convert unknown types to strings
111-
let stringValue = String(describing: value)
112-
return .string(stringValue)
113-
}
114-
}
115-
11698
/// Determines a `BuildConfiguration.Variant` (e.g., `.debug` or `.release`) from a configuration name.
11799
///
118100
/// Uses `ConfigurationMatcher` to infer the variant by analyzing the configuration name for known keywords.

0 commit comments

Comments
 (0)