Skip to content

Drop macOS requirement to 10.15 with availability annotations #38

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// swift-tools-version: 6.0
// swift-tools-version:5.9
import PackageDescription

let package = Package(
name: "ErrorKit",
defaultLocalization: "en",
platforms: [.macOS(.v13), .iOS(.v16), .tvOS(.v16), .watchOS(.v9), .macCatalyst(.v16)],
platforms: [.macOS(.v10_15), .iOS(.v16), .tvOS(.v16), .watchOS(.v9), .macCatalyst(.v16)],
products: [.library(name: "ErrorKit", targets: ["ErrorKit"])],
dependencies: [
// CryptoKit is not available on Linux, so we need Swift Crypto
Expand Down
1 change: 1 addition & 0 deletions Sources/ErrorKit/Helpers/Logger+ErrorKit.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#if canImport(OSLog)
import OSLog

@available(macOS 11, *)
extension Logger {
/// Logs a debug message with complete error chain description
///
Expand Down
14 changes: 8 additions & 6 deletions Sources/ErrorKit/Helpers/String+ErrorKit.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ import Foundation

extension String {
#if canImport(CryptoKit)
// On Apple platforms, use the modern localization API with Bundle.module
static func localized(key: StaticString, defaultValue: String.LocalizationValue) -> String {
return String(
localized: key,
defaultValue: defaultValue,
bundle: Bundle.module
// On Apple platforms, use the old localization API with Bundle.module
static func localized(key: StaticString, defaultValue: String) -> String {
return NSLocalizedString(
key.description,
tableName: nil,
bundle: Bundle.module,
value: defaultValue,
comment: defaultValue
)
}
#else
Expand Down
4 changes: 4 additions & 0 deletions Sources/ErrorKit/Logging/ErrorKit+OSLog.swift
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ extension ErrorKit {
/// ```
///
/// - See Also: ``exportLogFile(ofLast:minLevel:)`` for when you need a URL with the log content written to a text file
@available(macOS 13, *)
public static func loggedData(ofLast duration: Duration, minLevel: OSLogEntryLog.Level = .notice) throws -> Data {
let logStore = try OSLogStore(scope: .currentProcessIdentifier)

Expand All @@ -86,6 +87,7 @@ extension ErrorKit {
/// - Throws: Errors if log store access fails or if writing to the file fails
///
/// - See Also: ``loggedData(ofLast:minLevel:)`` for when you need the log content as Data directly
@available(macOS 13, *)
public static func exportLogFile(ofLast duration: Duration, minLevel: OSLogEntryLog.Level = .notice) throws -> URL {
let logData = try loggedData(ofLast: duration, minLevel: minLevel)

Expand Down Expand Up @@ -140,6 +142,7 @@ extension ErrorKit {
/// attachments: [logAttachment]
/// )
/// ```
@available(macOS 13, *)
public static func logAttachment(
ofLast duration: Duration,
minLevel: OSLogEntryLog.Level = .notice,
Expand All @@ -157,6 +160,7 @@ extension ErrorKit {
}
}

@available(macOS 13, *)
extension Duration {
/// Returns the duration as a `TimeInterval`.
///
Expand Down