From 464c8f73f02617125db591f6580df6a9221086a9 Mon Sep 17 00:00:00 2001 From: Maciek Grzybowski Date: Tue, 9 Jun 2020 08:22:31 +0200 Subject: [PATCH] RUMM-494 Hotfix for crash on iOS 11.0 - 11.1 --- DatadogSDK.podspec | 2 +- DatadogSDKObjc.podspec | 2 +- Sources/Datadog/Core/Utils/ISO8601DateFormatter.swift | 4 +++- Sources/Datadog/Datadog.swift | 2 +- Sources/Datadog/Logs/LogOutputs/LogConsoleOutput.swift | 6 +++++- Tests/DatadogTests/Matchers/LogMatcher.swift | 4 +++- 6 files changed, 14 insertions(+), 6 deletions(-) diff --git a/DatadogSDK.podspec b/DatadogSDK.podspec index 5ed9cbb230..fc4b4d2f8c 100644 --- a/DatadogSDK.podspec +++ b/DatadogSDK.podspec @@ -1,7 +1,7 @@ Pod::Spec.new do |s| s.name = "DatadogSDK" s.module_name = "Datadog" - s.version = "1.2.0" + s.version = "1.2.1" s.summary = "Official Datadog Swift SDK for iOS." s.homepage = "https://www.datadoghq.com" diff --git a/DatadogSDKObjc.podspec b/DatadogSDKObjc.podspec index 2352cd2c12..e30ea8b371 100644 --- a/DatadogSDKObjc.podspec +++ b/DatadogSDKObjc.podspec @@ -1,7 +1,7 @@ Pod::Spec.new do |s| s.name = "DatadogSDKObjc" s.module_name = "DatadogObjc" - s.version = "1.2.0" + s.version = "1.2.1" s.summary = "Official Datadog Objective-C SDK for iOS." s.homepage = "https://www.datadoghq.com" diff --git a/Sources/Datadog/Core/Utils/ISO8601DateFormatter.swift b/Sources/Datadog/Core/Utils/ISO8601DateFormatter.swift index f5a0bb3d04..0846e60512 100644 --- a/Sources/Datadog/Core/Utils/ISO8601DateFormatter.swift +++ b/Sources/Datadog/Core/Utils/ISO8601DateFormatter.swift @@ -9,7 +9,9 @@ import Foundation extension ISO8601DateFormatter { static func `default`() -> ISO8601DateFormatter { let formatter = ISO8601DateFormatter() - formatter.formatOptions.insert(.withFractionalSeconds) + if #available(iOS 11.2, *) { + formatter.formatOptions.insert(.withFractionalSeconds) + } return formatter } diff --git a/Sources/Datadog/Datadog.swift b/Sources/Datadog/Datadog.swift index ee6a84c15c..fddedb0cd8 100644 --- a/Sources/Datadog/Datadog.swift +++ b/Sources/Datadog/Datadog.swift @@ -8,7 +8,7 @@ import Foundation /// SDK version associated with logs. /// Should be synced with SDK releases. -internal let sdkVersion = "1.2.0" +internal let sdkVersion = "1.2.1" /// Datadog SDK configuration object. public class Datadog { diff --git a/Sources/Datadog/Logs/LogOutputs/LogConsoleOutput.swift b/Sources/Datadog/Logs/LogOutputs/LogConsoleOutput.swift index 4bbaf11149..7d68ee9580 100644 --- a/Sources/Datadog/Logs/LogOutputs/LogConsoleOutput.swift +++ b/Sources/Datadog/Logs/LogOutputs/LogConsoleOutput.swift @@ -16,7 +16,11 @@ internal struct LogConsoleOutput: LogOutput { /// Time formatter used for `.short` output format. static func shortTimeFormatter(calendar: Calendar = .current, timeZone: TimeZone = .current) -> Formatter { let formatter = ISO8601DateFormatter.default() - formatter.formatOptions = [.withFractionalSeconds, .withFullTime] + if #available(iOS 11.2, *) { + formatter.formatOptions = [.withFractionalSeconds, .withFullTime] + } else { + formatter.formatOptions = [.withFullTime] + } return formatter } diff --git a/Tests/DatadogTests/Matchers/LogMatcher.swift b/Tests/DatadogTests/Matchers/LogMatcher.swift index 3a06f1fa5e..de5ace3fd5 100644 --- a/Tests/DatadogTests/Matchers/LogMatcher.swift +++ b/Tests/DatadogTests/Matchers/LogMatcher.swift @@ -11,7 +11,9 @@ import XCTest struct LogMatcher { private static let dateFormatter: ISO8601DateFormatter = { let formatter = ISO8601DateFormatter() - formatter.formatOptions.insert(.withFractionalSeconds) + if #available(iOS 11.2, *) { + formatter.formatOptions.insert(.withFractionalSeconds) + } return formatter }()