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

Commit 3b37cf5

Browse files
committed
Finish removal of tuist specific information from build settings
1 parent 3342ed6 commit 3b37cf5

5 files changed

Lines changed: 12 additions & 116 deletions

File tree

Lines changed: 7 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,11 @@
11
import Foundation
2+
import XcodeProj
23

34
/// Keys representing various build settings that may appear in an Xcode project or workspace configuration.
45
enum BuildSettingKey: String {
56
case sdkroot = "SDKROOT"
6-
case compilerFlags = "COMPILER_FLAGS"
7-
case attributes = "ATTRIBUTES"
8-
case environmentVariables = "ENVIRONMENT_VARIABLES"
97
case codeSignOnCopy = "CODE_SIGN_ON_COPY"
10-
case dependencyFile = "DEPENDENCY_FILE"
11-
case inputPaths = "INPUT_PATHS"
12-
case outputPaths = "OUTPUT_PATHS"
13-
case showEnvVarsInLog = "SHOW_ENV_VARS_IN_LOG"
14-
case shellPath = "SHELL_PATH"
15-
case launchArguments = "LAUNCH_ARGUMENTS"
16-
case tags = "TAGS"
178
case mergedBinaryType = "MERGED_BINARY_TYPE"
18-
case prune = "PRUNE"
19-
case mergeable = "MERGEABLE"
209
case productBundleIdentifier = "PRODUCT_BUNDLE_IDENTIFIER"
2110
case infoPlistFile = "INFOPLIST_FILE"
2211
case codeSignEntitlements = "CODE_SIGN_ENTITLEMENTS"
@@ -27,75 +16,9 @@ enum BuildSettingKey: String {
2716
case visionOSDeploymentTarget = "VISIONOS_DEPLOYMENT_TARGET"
2817
}
2918

30-
//
31-
///// A protocol representing a type that can parse a build setting value from a generic `Any`.
32-
//protocol BuildSettingValue {
33-
// associatedtype Value
34-
// static func parse(_ any: Any) -> Value?
35-
//}
36-
//
37-
///// A type that parses build settings as strings.
38-
//enum BuildSettingString: BuildSettingValue {
39-
// static func parse(_ any: Any) -> String? {
40-
// any as? String
41-
// }
42-
//}
43-
//
44-
///// A type that parses build settings as arrays of strings.
45-
//enum BuildSettingStringArray: BuildSettingValue {
46-
// static func parse(_ any: Any) -> [String]? {
47-
// let arr = any as? [Any]
48-
// return arr?.compactMap { $0 as? String }
49-
// }
50-
//}
51-
//
52-
///// A type that parses build settings as booleans.
53-
//enum BuildSettingBool: BuildSettingValue {
54-
// static func parse(_ any: Any) -> Bool? {
55-
// any as? Bool
56-
// }
57-
//}
58-
//
59-
///// A type that parses build settings as dictionaries of strings to strings.
60-
//enum BuildSettingStringDict: BuildSettingValue {
61-
// static func parse(_ any: Any) -> [String: String]? {
62-
// any as? [String: String]
63-
// }
64-
//}
65-
//
66-
//extension [String: Any] {
67-
// /// Extracts a build setting value of a specified type from the dictionary.
68-
// ///
69-
// /// - Parameters:
70-
// /// - key: The `BuildSettingKey` to look up.
71-
// /// - type: The type conforming to `BuildSettingValue` indicating the expected value type.
72-
// /// - Returns: The parsed value if found and valid, or `nil` otherwise.
73-
// func extractBuildSetting<T: BuildSettingValue>(_ key: BuildSettingKey, as _: T.Type = T.self)
74-
// -> T.Value?
75-
// {
76-
// guard let value = self[key.rawValue] else { return nil }
77-
// return T.parse(value)
78-
// }
79-
//}
80-
//
81-
//extension [String: Any] {
82-
// /// Retrieves a string value for the given build setting key.
83-
// func string(for key: BuildSettingKey) -> String? {
84-
// extractBuildSetting(key, as: BuildSettingString.self)
85-
// }
86-
//
87-
// /// Retrieves an array of strings for the given build setting key.
88-
// func stringArray(for key: BuildSettingKey) -> [String]? {
89-
// extractBuildSetting(key, as: BuildSettingStringArray.self)
90-
// }
91-
//
92-
// /// Retrieves a boolean value for the given build setting key.
93-
// func bool(for key: BuildSettingKey) -> Bool? {
94-
// extractBuildSetting(key, as: BuildSettingBool.self)
95-
// }
96-
//
97-
// /// Retrieves a dictionary of strings for the given build setting key.
98-
// func stringDict(for key: BuildSettingKey) -> [String: String]? {
99-
// extractBuildSetting(key, as: BuildSettingStringDict.self)
100-
// }
101-
//}
19+
20+
extension BuildSettings {
21+
subscript(_ key: BuildSettingKey) -> BuildSetting? {
22+
self[key.rawValue]
23+
}
24+
}

Sources/XcodeGraphMapper/Mappers/Settings/XCConfigurationList+Helpers.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ extension XCConfigurationList {
1010
let configurationMatcher = ConfigurationMatcher()
1111
var results = [BuildConfiguration: String]()
1212
for config in buildConfigurations {
13-
if let value = config.buildSettings[key.rawValue]?.stringValue {
13+
if let value = config.buildSettings[key]?.stringValue {
1414
let variant = configurationMatcher.variant(for: config.name)
1515
let buildConfig = BuildConfiguration(name: config.name, variant: variant)
1616
results[buildConfig] = value
@@ -29,7 +29,7 @@ extension XCConfigurationList {
2929

3030
for key in keys {
3131
for config in buildConfigurations {
32-
if let value = config.buildSettings[key.rawValue]?.stringValue {
32+
if let value = config.buildSettings[key]?.stringValue {
3333
results[key] = value
3434
break // Once found, move to the next key
3535
}

Sources/XcodeGraphMapper/Mappers/Targets/PBXTarget+BuildSettings.swift

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,6 @@ import XcodeGraph
44
import XcodeProj
55

66
extension PBXTarget {
7-
// enum EnvironmentExtractor {
8-
// static func extract(from buildSettings: BuildSettings) -> [String: EnvironmentVariable] {
9-
// guard let envVars = buildSettings.stringDict(for: .environmentVariables) else {
10-
// return [:]
11-
// }
12-
// return envVars.reduce(into: [:]) { result, pair in
13-
// result[pair.key] = EnvironmentVariable(value: pair.value, isEnabled: true)
14-
// }
15-
// }
16-
// }
17-
187
/// Retrieves the path to the Info.plist file from the target's build settings.
198
///
209
/// - Returns: The `INFOPLIST_FILE` value if present, otherwise `nil`.
@@ -70,16 +59,6 @@ extension PBXTarget {
7059
)
7160
}
7261

73-
/// Extracts environment variables from all build configurations of the target.
74-
///
75-
/// If multiple configurations define the same environment variable, the last processed configuration takes precedence.
76-
// func extractEnvironmentVariables() -> [String: EnvironmentVariable] {
77-
// buildConfigurationList?.buildConfigurations.reduce(into: [:]) { result, config in
78-
// result.merge(EnvironmentExtractor.extract(from: config.buildSettings)) { current, _ in current
79-
// }
80-
// } ?? [:]
81-
// }
82-
8362
/// Returns the build settings from the "Debug" build configuration, or an empty dictionary if not present.
8463
var debugBuildSettings: [String: BuildSetting] {
8564
buildConfigurationList?.buildConfigurations.first(where: { $0.name == "Debug" })?.buildSettings

Sources/XcodeGraphMapper/Mappers/Targets/PBXTarget+GraphMapping.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import XcodeProj
66
extension PBXTarget {
77
/// Attempts to retrieve the bundle identifier from the target's debug build settings, or throws an error if missing.
88
func bundleIdentifier() throws -> String {
9-
if let bundleId = debugBuildSettings[BuildSettingKey.productBundleIdentifier.rawValue]?.stringValue {
9+
if let bundleId = debugBuildSettings[BuildSettingKey.productBundleIdentifier]?.stringValue {
1010
return bundleId
1111
} else {
1212
return "Unknown"
@@ -19,7 +19,7 @@ extension PBXTarget {
1919
}
2020

2121
func mergedBinaryType() throws -> MergedBinaryType {
22-
let mergedBinaryTypeString = debugBuildSettings[BuildSettingKey.mergedBinaryType.rawValue]?.stringValue
22+
let mergedBinaryTypeString = debugBuildSettings[BuildSettingKey.mergedBinaryType]?.stringValue
2323
return mergedBinaryTypeString == "automatic" ? .automatic : .disabled
2424
}
2525

Sources/XcodeGraphMapper/Mappers/Targets/PBXTargetMapper.swift

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -189,22 +189,16 @@ struct PBXTargetMapper: PBXTargetMapping {
189189
// Build Rules
190190
let buildRules = try pbxTarget.buildRules.compactMap { try buildRuleMapper.map($0) }
191191

192-
// Environment & Launch
193-
// let environmentVariables = pbxTarget.extractEnvironmentVariables()
194-
// let launchArguments = try pbxTarget.launchArguments()
195-
196192
// Files group
197193
let filesGroup = try extractFilesGroup(from: pbxTarget, xcodeProj: xcodeProj)
198194

199195
// Swift Playgrounds
200196
let playgrounds = try extractPlaygrounds(from: pbxTarget, xcodeProj: xcodeProj)
201197

202198
// Misc
203-
// let prune = try pbxTarget.prune()
204199
let mergedBinaryType = try pbxTarget.mergedBinaryType()
205-
// let mergeable = try pbxTarget.mergeable()
206200
let onDemandResourcesTags = try pbxTarget.onDemandResourcesTags()
207-
// let metadata = try pbxTarget.metadata()
201+
208202

209203
// Dependencies
210204
let projectNativeTargets = try pbxTarget.dependencies.compactMap {

0 commit comments

Comments
 (0)