 public func buildScheme(scheme: String, inProject project: ProjectLocator, #workingDirectoryURL: NSURL, configuration: String? = nil) -> ColdSignal<()> {
 	precondition(workingDirectoryURL.fileURL)
 
-	var configurationArguments: [String] = []
-	if let configuration = configuration {
-		configurationArguments += [ "-configuration", "\(configuration)" ]
-	}
-
 	let handle = NSFileHandle.fileHandleWithStandardOutput()
 	let stdoutSink = SinkOf<NSData> { data in
 		handle.writeData(data)
 	}
 
 	let buildPlatform = { (platform: Platform?) -> ColdSignal<NSData> in
-		var buildScheme = xcodebuildTask(project.arguments + configurationArguments + [ "-scheme", scheme ])
-		if let platform = platform {
-			buildScheme.arguments += platform.arguments
-		}
-
-		buildScheme.arguments.append("build")
+		var buildScheme = xcodebuildTask([ "build" ], project: project, platform: platform, scheme: scheme, configuration: configuration)
 		buildScheme.workingDirectoryPath = workingDirectoryURL.path!
 
 		return launchTask(buildScheme, standardOutput: stdoutSink)


/// Creates a task description for executing `xcodebuild` in the given directory
/// and with the given arguments.
public func xcodebuildTask(arguments: [String]) -> TaskDescription {
	var arguments = [ "xcodebuild" ] + arguments
	return TaskDescription(launchPath: "/usr/bin/xcrun", arguments: arguments)
}

/// Sends each scheme found in the given project.
public func schemesInProject(project: ProjectLocator) -> ColdSignal<String> {
	let task = xcodebuildTask(project.arguments + [ "-list" ])
	return launchTask(task)
		.map { (data: NSData) -> String in
			return NSString(data: data, encoding: NSStringEncoding(NSUTF8StringEncoding))!


/// Returns the value for the given build setting, or an error if it could not
/// be determined.
private func valueForBuildSetting(setting: String, withScheme scheme: String, inProject project: ProjectLocator, configuration: String? = nil) -> ColdSignal<String> {
	let task = xcodebuildTask([ "-showBuildSettings" ], project: project, scheme: scheme, configuration: configuration)

	return launchTask(task)
		.map { (data: NSData) -> String in
			return NSString(data: data, encoding: NSStringEncoding(NSUTF8StringEncoding))!
