Skip to content

Commit 5dff0da

Browse files
committed
Updates for Swift 6.1
Updated to Gauntlet 2.2.0. Changed public types to Sendable.
1 parent dc96cc0 commit 5dff0da

17 files changed

Lines changed: 42 additions & 36 deletions

File tree

Cache.xcworkspace/xcshareddata/swiftpm/Package.resolved

Lines changed: 4 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Package.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
1-
// swift-tools-version: 5.7
1+
// swift-tools-version: 6.1
22
// The swift-tools-version declares the minimum version of Swift required to build this package.
33

44
import PackageDescription
55

66
let package = Package(
77
name: "Cache",
88
platforms: [
9-
.iOS(.v14),
10-
.macOS(.v12)
9+
.iOS(.v16),
10+
.macOS(.v13)
1111
],
1212
products: [
1313
.library(
1414
name: "Cache",
1515
targets: ["Cache"])
1616
],
1717
dependencies: [
18-
.package(url: "https://github.com/krogerco/Gauntlet-iOS.git", from: Version(1, 0, 0))
18+
.package(url: "https://github.com/krogerco/Gauntlet-iOS.git", from: "2.2.0")
1919
],
2020
targets: [
2121
.target(name: "Cache"),
2222
.testTarget(
2323
name: "CacheTests",
2424
dependencies: [
2525
.byName(name: "Cache"),
26-
.product(name: "Gauntlet", package: "Gauntlet-iOS")
26+
.product(name: "GauntletLegacy", package: "Gauntlet-iOS")
2727
]
2828
)
2929
]

Sources/Cache/Cache.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import Foundation
2626
typealias EventPublisher = PassthroughSubject<CacheEvent, Never>
2727

2828
/// A memory based cache with configurable policies and optional persistence.
29-
public final class Cache<Key: CacheKey, Value: Codable> {
29+
public final class Cache<Key: CacheKey, Value: Codable>: @unchecked Sendable {
3030
let lock = NSRecursiveLock()
3131
let layer: MemoryCacheLayer<Key, Value>
3232
let identifier: String

Sources/Cache/CacheConfig.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
import Combine
2424
import Foundation
2525

26-
class CacheConfig {
26+
struct CacheConfig {
2727
let location: CacheLocation?
2828
let eventPublisher: EventPublisher
2929

Sources/Cache/CacheEvent.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
import Foundation
2424

2525
/// Cache internal events that might be useful for debugging.
26-
public enum CacheEvent {
26+
public enum CacheEvent: Sendable {
2727
/// Cache was unable to load from the file. Will happen on first launch or if the Value type changes.
2828
case unableToLoad(URL, Error)
2929

Sources/Cache/CacheKey.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@
2323
import Foundation
2424

2525
/// The key used to look items up in cache objects.
26-
public typealias CacheKey = Hashable & Codable
26+
public typealias CacheKey = Hashable & Codable & Sendable

Sources/Cache/CacheLayer/MemoryCacheLayer.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import UIKit
2828
#endif
2929

3030
/// A fully in-memory based cache with persistence.
31-
final class MemoryCacheLayer<Key: CacheKey, Value: Codable>: CacheLayer {
31+
final class MemoryCacheLayer<Key: CacheKey, Value: Codable>: CacheLayer, @unchecked Sendable {
3232
var config = CacheConfig()
3333
let policies: [CachePolicy]
3434
var cache: [Key: Item] = [:]
@@ -89,16 +89,16 @@ final class MemoryCacheLayer<Key: CacheKey, Value: Codable>: CacheLayer {
8989
object: nil,
9090
queue: .main
9191
) { [weak self] _ in
92-
guard let strongSelf = self else { return }
92+
guard let self else { return }
9393

94-
strongSelf.lock.lock(); defer { strongSelf.lock.unlock() }
94+
lock.lock(); defer { lock.unlock() }
9595

9696
// Bail if empty.
97-
guard !strongSelf.cache.isEmpty else { return }
97+
guard !cache.isEmpty else { return }
9898

9999
// Apply a policy that will purge half of the current cache.
100-
let purgeAmount = strongSelf.cache.count / 2
101-
strongSelf.apply([.maxItemCount(purgeAmount)])
100+
let purgeAmount = cache.count / 2
101+
apply([.maxItemCount(purgeAmount)])
102102
}
103103
#endif
104104
}

Sources/Cache/CacheLocation.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
import Foundation
2424

2525
/// Specifies a directory where ``CacheLayer``s are stored.
26-
public struct CacheLocation {
26+
public struct CacheLocation: Sendable {
2727
/// Name of this location.
2828
public let locationName: String
2929

Sources/Cache/CachePolicy.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import Foundation
2525
/// Policies that may be applied to each cache source.
2626
/// Generally, you would create a different and more lenient policy for each level of cache source.
2727
/// Specifying no policies results in caches with unbounded growth.
28-
public enum CachePolicy {
28+
public enum CachePolicy: Sendable {
2929
/// The maximum number of key/values the source should track.
3030
/// When this count is exceeded, the least recently used values will be purged.
3131
case maxItemCount(Int)

Sources/DemoApp/DemoApp.xcodeproj/project.pbxproj

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@
160160
attributes = {
161161
BuildIndependentTargetsInParallel = 1;
162162
LastSwiftUpdateCheck = 1420;
163-
LastUpgradeCheck = 1420;
163+
LastUpgradeCheck = 1630;
164164
TargetAttributes = {
165165
6732C75029BBAD7100D13B5C = {
166166
CreatedOnToolsVersion = 14.2;
@@ -297,6 +297,7 @@
297297
DEBUG_INFORMATION_FORMAT = dwarf;
298298
ENABLE_STRICT_OBJC_MSGSEND = YES;
299299
ENABLE_TESTABILITY = YES;
300+
ENABLE_USER_SCRIPT_SANDBOXING = YES;
300301
GCC_C_LANGUAGE_STANDARD = gnu11;
301302
GCC_DYNAMIC_NO_PIC = NO;
302303
GCC_NO_COMMON_BLOCKS = YES;
@@ -357,6 +358,7 @@
357358
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
358359
ENABLE_NS_ASSERTIONS = NO;
359360
ENABLE_STRICT_OBJC_MSGSEND = YES;
361+
ENABLE_USER_SCRIPT_SANDBOXING = YES;
360362
GCC_C_LANGUAGE_STANDARD = gnu11;
361363
GCC_NO_COMMON_BLOCKS = YES;
362364
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
@@ -398,7 +400,7 @@
398400
PRODUCT_BUNDLE_IDENTIFIER = com.kroger.DemoApp;
399401
PRODUCT_NAME = "$(TARGET_NAME)";
400402
SWIFT_EMIT_LOC_STRINGS = YES;
401-
SWIFT_VERSION = 5.0;
403+
SWIFT_VERSION = 6.0;
402404
TARGETED_DEVICE_FAMILY = "1,2";
403405
};
404406
name = Debug;
@@ -426,15 +428,14 @@
426428
PRODUCT_BUNDLE_IDENTIFIER = com.kroger.DemoApp;
427429
PRODUCT_NAME = "$(TARGET_NAME)";
428430
SWIFT_EMIT_LOC_STRINGS = YES;
429-
SWIFT_VERSION = 5.0;
431+
SWIFT_VERSION = 6.0;
430432
TARGETED_DEVICE_FAMILY = "1,2";
431433
};
432434
name = Release;
433435
};
434436
6732C77929BBAD7200D13B5C /* Debug */ = {
435437
isa = XCBuildConfiguration;
436438
buildSettings = {
437-
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
438439
BUNDLE_LOADER = "$(TEST_HOST)";
439440
CODE_SIGN_STYLE = Automatic;
440441
CURRENT_PROJECT_VERSION = 1;
@@ -453,7 +454,6 @@
453454
6732C77A29BBAD7200D13B5C /* Release */ = {
454455
isa = XCBuildConfiguration;
455456
buildSettings = {
456-
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
457457
BUNDLE_LOADER = "$(TEST_HOST)";
458458
CODE_SIGN_STYLE = Automatic;
459459
CURRENT_PROJECT_VERSION = 1;

0 commit comments

Comments
 (0)