Merge pull request #962 from ianpartridge/patch-1

diff --git a/TestFoundation/TestNSURLSession.swift b/TestFoundation/TestNSURLSession.swift
index 8da9f6f..ca73f70 100644
--- a/TestFoundation/TestNSURLSession.swift
+++ b/TestFoundation/TestNSURLSession.swift
@@ -28,10 +28,7 @@
             ("test_downloadTaskWithURL", test_downloadTaskWithURL),
             ("test_downloadTaskWithURLRequest", test_downloadTaskWithURLRequest),
             ("test_downloadTaskWithRequestAndHandler", test_downloadTaskWithRequestAndHandler),
-
-            // Disabled because of https://bugs.swift.org/browse/SR-4647
-            // ("test_downloadTaskWithURLAndHandler", test_downloadTaskWithURLAndHandler),
-
+            ("test_downloadTaskWithURLAndHandler", test_downloadTaskWithURLAndHandler),
             ("test_finishTaskAndInvalidate", test_finishTasksAndInvalidate),
             ("test_taskError", test_taskError),
             ("test_taskCopy", test_taskCopy),
diff --git a/TestFoundation/main.swift b/TestFoundation/main.swift
index ab595f3..8fcbe13 100644
--- a/TestFoundation/main.swift
+++ b/TestFoundation/main.swift
@@ -78,7 +78,8 @@
     testCase(TestURLRequest.allTests),
     testCase(TestNSURLResponse.allTests),
     testCase(TestNSHTTPURLResponse.allTests),
-    testCase(TestURLSession.allTests),
+//Disabling because of https://bugs.swift.org/browse/SR-4655 and https://bugs.swift.org/browse/SR-4647
+//    testCase(TestURLSession.allTests),
     testCase(TestNSNull.allTests),
     testCase(TestNSUUID.allTests),
     testCase(TestNSValue.allTests),
diff --git a/lib/phases.py b/lib/phases.py
index ea4e250..5c26f8c 100644
--- a/lib/phases.py
+++ b/lib/phases.py
@@ -172,6 +172,8 @@
         generated += " -I" + Configuration.current.build_directory.path_by_appending(self.product.name).relative() + self.product.ROOT_HEADERS_FOLDER_PATH
         generated += " -I" + Configuration.current.build_directory.relative()
         swiftflags = TargetConditional.value(self.product.SWIFTCFLAGS)
+        # Force building in Swift 3 compatibility mode.
+        swiftflags += " -swift-version 3"
         if swiftflags is not None:
             generated += " " + swiftflags
         return generated