             buildSettings += SettingsPresetFile.config(type).getBuildSettings()
         }
 
+        // Prevent setting presets from overrwriting settings in project xcconfig files
         if let configPath = configFiles[config.name] {
-            // Do not overwrite project xcconfig's value.
-            if let configFile = try? XCConfig(path: basePath + configPath) {
-                removeValues(for: configFile.flattenedBuildSettings().keys, buildSettings: &buildSettings)
-            }
+            buildSettings = removeConfigFileSettings(from: buildSettings, configPath: configPath)
         }
 
         buildSettings += getBuildSettings(settings: settings, config: config)

        let buildSettings = getCombinedBuildSettings(basePath: basePath, target: target, config: config, includeProject: includeProject)
        return buildSettings[setting] != nil
    }

    // MARK: private

    /// Removes values for specified keys in buildSettings
    /// - parameter keys: Keys for values to remove
    /// - paramerter buildSettings: inout dictionary
    private func removeValues(for keys: BuildSettings.Keys, buildSettings: inout BuildSettings) {
        for k in keys {
            // FIXME: Catch platform specifier. e.g. LD_RUNPATH_SEARCH_PATHS[sdk=iphone*]
            buildSettings.removeValue(forKey: k)
            buildSettings.removeValue(forKey: "\"\(k)\"")
        }
    }
}


            buildSettings += SettingsPresetFile.productPlatform(target.type, target.platform).getBuildSettings()
        }

        // Prevent setting presets from overrwriting settings in target xcconfig files
        if let configPath = target.configFiles[config.name] {
            buildSettings = removeConfigFileSettings(from: buildSettings, configPath: configPath)
        }
        // Prevent setting presets from overrwriting settings in project xcconfig files
        if let configPath = configFiles[config.name] {
            buildSettings = removeConfigFileSettings(from: buildSettings, configPath: configPath)
        }

        buildSettings += getBuildSettings(settings: target.settings, config: config)
