From 562cc57a28f4407987da8f9fb5f4f27623d88b19 Mon Sep 17 00:00:00 2001 From: jamesrochabrun Date: Mon, 7 Sep 2026 21:54:01 -0700 Subject: [PATCH 1/2] Declare Linux transport dependencies explicitly Declare the SwiftNIO products imported by the Linux adapter and verify both locked and freshly resolved dependencies in clean Linux CI builds. --- .github/workflows/ci.yml | 23 ++++++++++++++++++----- Package.swift | 4 ++++ 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 88476311..72367bfc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,8 +23,16 @@ jobs: build_and_test_linux: runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + include: + - image: swift:6.0.1-jammy + dependencies: locked + - image: swift:6.2-jammy + dependencies: latest container: - image: swift:6.0.1-jammy + image: ${{ matrix.image }} steps: - name: Install dependencies run: | @@ -33,10 +41,15 @@ jobs: - uses: actions/checkout@v4 - name: Get swift version run: swift --version - - name: Build - run: swift build -q + - name: Resolve current compatible dependencies + if: matrix.dependencies == 'latest' + run: swift package update + - name: Clean build + run: | + swift package clean + swift build -q --force-resolved-versions - name: Run tests - run: swift test -q + run: swift test -q --force-resolved-versions lint: runs-on: macos-latest @@ -48,4 +61,4 @@ jobs: - name: Install swiftformat run: brew install swiftformat - name: Check formatting - run: swiftformat --config rules.swiftformat --lint . \ No newline at end of file + run: swiftformat --config rules.swiftformat --lint . diff --git a/Package.swift b/Package.swift index 50f2327f..53104c1d 100644 --- a/Package.swift +++ b/Package.swift @@ -18,6 +18,7 @@ let package = Package( ], dependencies: [ .package(url: "https://github.com/swift-server/async-http-client.git", from: "1.25.2"), + .package(url: "https://github.com/apple/swift-nio.git", from: "2.78.0"), ], targets: [ // Targets are the basic building blocks of a package, defining a module or a test suite. @@ -26,6 +27,9 @@ let package = Package( name: "SwiftOpenAI", dependencies: [ .product(name: "AsyncHTTPClient", package: "async-http-client", condition: .when(platforms: [.linux])), + .product(name: "NIOCore", package: "swift-nio", condition: .when(platforms: [.linux])), + .product(name: "NIOFoundationCompat", package: "swift-nio", condition: .when(platforms: [.linux])), + .product(name: "NIOHTTP1", package: "swift-nio", condition: .when(platforms: [.linux])), ]), .testTarget( name: "SwiftOpenAITests", From bbdef8a04e68ff1cf7246fc4b76fa921b79d2e08 Mon Sep 17 00:00:00 2001 From: jamesrochabrun Date: Mon, 7 Sep 2026 21:59:23 -0700 Subject: [PATCH 2/2] Apply implicit return style required by the formatter Remove redundant returns from three files so the full repository lint check passes with the current formatter. --- .../SharedUI/ChatDisplayMessageView.swift | 8 ++++---- Sources/OpenAI/Private/Audio/AudioUtils.swift | 2 +- .../Public/ResponseModels/Response/ResponseModel.swift | 8 ++++---- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Examples/SwiftOpenAIExample/SwiftOpenAIExample/SharedUI/ChatDisplayMessageView.swift b/Examples/SwiftOpenAIExample/SwiftOpenAIExample/SharedUI/ChatDisplayMessageView.swift index 8e2a27c2..2d6841c7 100644 --- a/Examples/SwiftOpenAIExample/SwiftOpenAIExample/SharedUI/ChatDisplayMessageView.swift +++ b/Examples/SwiftOpenAIExample/SwiftOpenAIExample/SharedUI/ChatDisplayMessageView.swift @@ -18,17 +18,17 @@ struct ChatDisplayMessageView: View { case .content(let content): let text = content.compactMap { contentItem -> String? in if case .text(let text) = contentItem { - return text + text } else { - return nil + nil } }.first ?? "" let urls = content.compactMap { contentItem -> URL? in if case .imageUrl(let imageDetail) = contentItem { - return imageDetail.url + imageDetail.url } else { - return nil + nil } } VStack(alignment: .leading, spacing: 8) { diff --git a/Sources/OpenAI/Private/Audio/AudioUtils.swift b/Sources/OpenAI/Private/Audio/AudioUtils.swift index 5c758040..8d8f3bdc 100644 --- a/Sources/OpenAI/Private/Audio/AudioUtils.swift +++ b/Sources/OpenAI/Private/Audio/AudioUtils.swift @@ -188,7 +188,7 @@ nonisolated private func isBuiltInHeadphonePort(deviceID: AudioDeviceID) -> Bool mElement: kAudioObjectPropertyElementMain) let err = withUnsafeMutablePointer(to: &deviceUID) { ptr -> OSStatus in - return AudioObjectGetPropertyData( + AudioObjectGetPropertyData( deviceID, &address, 0, diff --git a/Sources/OpenAI/Public/ResponseModels/Response/ResponseModel.swift b/Sources/OpenAI/Public/ResponseModels/Response/ResponseModel.swift index 8173a3e7..28b3f0eb 100644 --- a/Sources/OpenAI/Public/ResponseModels/Response/ResponseModel.swift +++ b/Sources/OpenAI/Public/ResponseModels/Response/ResponseModel.swift @@ -199,17 +199,17 @@ public struct ResponseModel: Decodable { let outputTextItems = output.compactMap { outputItem -> String? in switch outputItem { case .message(let message): - return message.content.compactMap { contentItem -> String? in + message.content.compactMap { contentItem -> String? in switch contentItem { case .outputText(let outputText): - return outputText.text + outputText.text case .refusal: - return nil + nil } }.joined() default: - return nil + nil } }