     let hasDiagnosticReportDataJsonPath: [JSONSubscriptType] = ["HasDiagnosticReportData"]
     let diagnosticReportFileNameJsonPath: [JSONSubscriptType] = ["DiagnosticReportFileName"]
     let uuidJsonPath: [JSONSubscriptType] = ["UUID"]
+    let deviceNamePath: [JSONSubscriptType] = ["RunDestination", "Target Device", "ModelName"]
+    let deviceOSPath: [JSONSubscriptType] = ["RunDestination", "Target Device", "OperatingSystemVersionWithBuildNumber"]
 
     let testableSummariesJsons = testSummariesPlistJson[testableSummariesJsonPath].arrayValue
+    let testDeviceName = testSummariesPlistJson[deviceNamePath].stringValue
+    let testDeviceOSVersion = testSummariesPlistJson[deviceOSPath].stringValue
+
     var totalTestsCount = 0
     var totalFailuresCount = 0
     for testableSummaryJson in testableSummariesJsons {
-        let targetName = testableSummaryJson[targetNameJsonPath].stringValue
+        // With Xcode 9, the top-level "TestName" in the testable summary is the target name
+        let targetName: String = {
+            let targetName = testableSummaryJson[targetNameJsonPath].stringValue
+            return !targetName.isEmpty ? targetName : testableSummaryJson[testNameJsonPath].stringValue
+        }()
+
         let testSuitesJsons = testableSummaryJson.values(relativePath: testSuitesJsonPath)
 
         for testSuitesJson in testSuitesJsons {

    if subDirectory.isEmpty {
        return path
    }

    return path.last == "/" ? path + subDirectory : path + "/" + subDirectory
}



if let screenshotsPathOptionValue = screenshotsPathOptionValue {
    argumentOptionsParser.validateOptionIsNotEmpty(optionName: screenshotsPathOption, optionValue: screenshotsPathOptionValue)

    var fileCount = 1
    var subDirectory = testSummariesPlistJsons.count > 1 ? "\(fileCount)" : ""

    testSummariesPlistJsons.forEach { testSummariesPlistJson in
    saveLastScreenshots(testSummariesPlistJson: testSummariesPlistJson, logsTestPath: logsTestPath, lastScreenshotsPath: appendSubdirectoryToPath(screenshotsPathOptionValue, subDirectory: subDirectory), screenshotsCount: screenshotsCount, excludeIdenticalScreenshots: excludeIdenticalScreenshots)
        fileCount += 1
        subDirectory = "\(fileCount)"
    }

}

// generate the report if --jUnitReportPath option is passed
if let jUnitReportPathOptionValue = jUnitReportPathOptionValue {
    argumentOptionsParser.validateOptionIsNotEmpty(optionName: jUnitReportPathOption, optionValue: jUnitReportPathOptionValue)

    let path = getFolderPathFromFilePath(jUnitReportPathOptionValue)
    let fileName = URL(fileURLWithPath: jUnitReportPathOptionValue).lastPathComponent

    var fileCount = 1
    var subDirectory = testSummariesPlistJsons.count > 1 ? "\(fileCount)" : ""

    testSummariesPlistJsons.forEach { testSummariesPlistJson in
        generateJUnitReport(testSummariesPlistJson: testSummariesPlistJson, logsTestPath: logsTestPath, jUnitRepPath: appendSubdirectoryToPath(path, subDirectory: subDirectory) + fileName, noCrashLogs: noCrashLogs, lastScreenshotsPath: screenshotsPathOptionValue, screenshotsCount: screenshotsCount, buildUrl: buildUrlOptionValue, workspacePath: workspacePathOptionValue ?? "")
        fileCount += 1
        subDirectory = "\(fileCount)"
    }
