Skip to content

Commit dca08b2

Browse files
committed
fix concurrency problems for Swift 6
1 parent 881f151 commit dca08b2

26 files changed

+46
-44
lines changed

Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import PackageDescription
66
let package = Package(
77
name: "AnthropicSwiftSDK",
88
platforms: [
9-
.iOS(.v17),
9+
.iOS(.v18),
1010
.macOS(.v15)
1111
],
1212
products: [

Sources/AnthropicSwiftSDK-TestUtils/HTTPMock.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public enum MockInspectType {
1616
}
1717

1818
public class HTTPMock: URLProtocol {
19-
public static var inspectType: MockInspectType = .none
19+
nonisolated(unsafe) public static var inspectType: MockInspectType = .none
2020

2121
public override class func canInit(with request: URLRequest) -> Bool {
2222
return true

Sources/AnthropicSwiftSDK/AnthropicAPIError.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import Foundation
1010
/// The error returned from the Anthropic API
1111
///
1212
/// for more detail, see https://docs.anthropic.com/claude/reference/errors
13-
public enum AnthropicAPIError: String, Decodable, Error {
13+
public enum AnthropicAPIError: String, Decodable, Error, Sendable {
1414
case invalidRequestError = "invalid_request_error"
1515
case authenticationError = "authentication_error"
1616
case permissionError = "permission_error"

Sources/AnthropicSwiftSDK/ClientError.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import Foundation
99

1010
/// Errors in swift SDK
11-
public enum ClientError: Error {
11+
public enum ClientError: Error, @unchecked Sendable {
1212
/// Received unknown event in Stream.
1313
case unknownStreamingEvent(String)
1414
/// Received in Stream with unknown line type.

Sources/AnthropicSwiftSDK/Entity/Batch/BatchRequestCounts.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public struct BatchRequestCounts: Decodable {
1212
/// Number of requests in the Message Batch that have completed successfully.
1313
///
1414
/// This is zero until processing of the entire Message Batch has ended.
15-
let succeeeded: Int
15+
let succeeded: Int
1616
/// Number of requests in the Message Batch that encountered an error.
1717
///
1818
/// This is zero until processing of the entire Message Batch has ended.

Sources/AnthropicSwiftSDK/Entity/Content/Content.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import Foundation
99

1010
/// Type of content block.
11-
public enum ContentType: String {
11+
public enum ContentType: String, Sendable {
1212
/// single string
1313
case text
1414
/// image content
@@ -26,7 +26,7 @@ public enum ContentType: String {
2626
/// Each input message `content` may be either a single `string` or an array of content blocks, where each block has a specific `type`. Using a `string` for `content` is shorthand for an array of one content block of type `text`.
2727
///
2828
/// Starting with Claude 3 models, you can also send `image` content blocks.
29-
public enum Content {
29+
public enum Content: Sendable {
3030
/// a single string
3131
case text(String, cacheControl: CacheControl? = nil)
3232
/// currently supported the `base64` source type for images, and the `image/jpeg`, `image/png`, `image/gif`, and `image/webp` media types.

Sources/AnthropicSwiftSDK/Entity/Content/DocumentContent.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66
//
77
import Foundation
88

9-
public struct DocumentContent {
10-
public enum DocumentContentType: String, Codable {
9+
public struct DocumentContent: Sendable {
10+
public enum DocumentContentType: String, Codable, Sendable {
1111
case base64
1212
}
1313

14-
public enum DocumentContentMediaType: String, Codable {
14+
public enum DocumentContentMediaType: String, Codable, Sendable {
1515
case pdf = "application/pdf"
1616
}
1717

Sources/AnthropicSwiftSDK/Entity/Content/ImageContent.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@
88
import Foundation
99

1010
/// Object for image content.
11-
public struct ImageContent {
11+
public struct ImageContent: Sendable {
1212
/// currently support the base64 source type for images
13-
public enum ImageContentType: String, Codable {
13+
public enum ImageContentType: String, Codable, Sendable {
1414
case base64
1515
}
1616

1717
/// currently support the image/jpeg, image/png, image/gif, and image/webp media types.
18-
public enum ImageContentMediaType: String, Codable {
18+
public enum ImageContentMediaType: String, Codable, Sendable {
1919
case jpeg = "image/jpeg"
2020
case png = "image/png"
2121
case gif = "image/gif"

Sources/AnthropicSwiftSDK/Entity/Content/ToolResultContent.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import Foundation
99

10-
public struct ToolResultContent {
10+
public struct ToolResultContent: Sendable {
1111
/// The `id of the tool use request this is a result for
1212
public let toolUseId: String
1313
/// The result of the tool, as a string (e.g. `"content": "15 degrees"` ) or

Sources/AnthropicSwiftSDK/Entity/Content/ToolUseContent.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import Foundation
99

10-
public struct ToolUseContent {
10+
public struct ToolUseContent: @unchecked Sendable {
1111
/// A unique identifier for this particular tool use block.
1212
/// This will be used to match up the tool results later.
1313
public let id: String

0 commit comments

Comments
 (0)