Skip to content

Commit ef9f4d8

Browse files
committed
fix: make Core config helpers linux-friendly
1 parent 8447985 commit ef9f4d8

File tree

4 files changed

+11
-4
lines changed

4 files changed

+11
-4
lines changed

Core/Sources/Core/Configs/BoolConfigItem.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ protocol BoolConfigItem: ConfigItem<Bool> {
77
extension BoolConfigItem {
88
public var value: Bool {
99
get {
10-
if let value = UserDefaults.standard.value(forKey: Self.key) {
10+
if let value = UserDefaults.standard.object(forKey: Self.key) {
1111
value as? Bool ?? Self.default
1212
} else {
1313
Self.default

Core/Sources/Core/Configs/CustomCodableConfigItem.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ extension Config {
209209
public static var `default`: Value {
210210
// Migration: If user had OpenAI API enabled, preserve that setting
211211
let legacyKey = Config.Deprecated.EnableOpenAiApiKey.key
212-
if let legacyValue = UserDefaults.standard.value(forKey: legacyKey) as? Bool,
212+
if let legacyValue = UserDefaults.standard.object(forKey: legacyKey) as? Bool,
213213
legacyValue {
214214
return .openAI
215215
}

Core/Sources/Core/Configs/CustomInputTableStore.swift

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
import Foundation
2+
#if canImport(UniformTypeIdentifiers)
3+
import UniformTypeIdentifiers
4+
#endif
25
import KanaKanjiConverterModule
36

47
public enum CustomInputTableStore {
@@ -15,7 +18,11 @@ public enum CustomInputTableStore {
1518
}
1619

1720
static var fileURL: URL {
18-
directoryURL.appendingPathComponent(fileName, conformingTo: .text)
21+
#if canImport(UniformTypeIdentifiers) && !os(Linux)
22+
return directoryURL.appendingPathComponent(fileName, conformingTo: .text)
23+
#else
24+
return directoryURL.appendingPathComponent(fileName)
25+
#endif
1926
}
2027

2128
@discardableResult

Core/Sources/Core/Configs/IntConfigItem.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ protocol IntConfigItem: ConfigItem<Int> {
77
extension IntConfigItem {
88
public var value: Int {
99
get {
10-
if let value = UserDefaults.standard.value(forKey: Self.key) {
10+
if let value = UserDefaults.standard.object(forKey: Self.key) {
1111
value as? Int ?? Self.default
1212
} else {
1313
Self.default

0 commit comments

Comments
 (0)