Skip to content

Migrate to Swift 6#113

Open
jmarek41 wants to merge 31 commits intomainfrom
feature/request-configuring
Open

Migrate to Swift 6#113
jmarek41 wants to merge 31 commits intomainfrom
feature/request-configuring

Conversation

@jmarek41
Copy link
Member

@jmarek41 jmarek41 commented Mar 17, 2026

Breaking

  • All errors (network, HTTP status, decoding) now route through URLServer.ErrorType
  • Removed Combine support, completion handler API, and Server protocol
  • Removed CocoaPods, Linux support

Added

  • RequestConfiguring protocol for per-request async configuration at call site
  • CompositeRequestConfiguring for composing multiple configurations
  • NetworkObserver protocol for request lifecycle monitoring with type-safe context
  • URLServer: Sendable requirement for Swift 6 concurrency safety
  • Xcode file templates updated for v2 API

Changed

  • buildRequest(endpoint:) is now async throws
  • Download merged into URLServer+Async.swift (all helpers now private)
  • Tests migrated from XCTest to Swift Testing framework

Removed

  • Server protocol (replaced by URLServer)
  • Combine publishers (URLServer+Combine.swift)
  • Completion handler API (URLServer+Call.swift, URLServer+Task.swift)
  • CocoaPods support (FTAPIKit.podspec, Gemfile)
  • Redundant CI workflows (ubuntu, macos-15)

Šimon Šesták and others added 30 commits January 20, 2026 14:22
- Update swift-tools-version from 5.1 to 6.1
- Remove redundant Package@swift-5.5.swift (consolidated into Package.swift)
- Update minimum deployment targets:
  - iOS 12 → 15
  - macOS 10.10 → 12
  - tvOS 12 → 15
  - watchOS 5 → 8
- Update podspec Swift version to 6.1
- Remove CoreServices framework dependency (no longer needed)

BREAKING CHANGE: Minimum deployment targets have been raised to support Swift 6.1 concurrency features.

# Conflicts:
#	Package.swift
…etection

- Remove CoreServices framework usage (deprecated)
- Simplify URL+MIME.swift by removing fallback code for pre-macOS 11/iOS 14
- Use UniformTypeIdentifiers exclusively on Apple platforms
- Reduce code complexity by ~40 lines
- Keep Linux support using file command

With minimum deployment targets now at macOS 12+/iOS 15+, we no longer need
the CoreServices fallback since UniformTypeIdentifiers is available on all
supported OS versions.
- Require Response types to conform to Sendable in ResponseEndpoint protocol
- Add Sendable conformance to User test model
- Remove redundant Sendable constraint from async function signature

BREAKING CHANGE: All ResponseEndpoint.Response types must now conform to
Sendable. This enforces Swift 6 concurrency safety at compile time and
provides clear error messages at the endpoint definition site rather than
at the call site.

This design choice improves developer experience by failing fast with clear
errors when defining endpoints with non-Sendable response types, rather than
discovering issues later when calling async functions.
- Change static var to static let for immutable global state:
  - APIError+Standard.swift: unhandled property
  - Test mock Errors.swift: unhandled property
  - Test files: allTests arrays
- Fix SwiftLint violations:
  - EndpointPublisher: Use proper nesting disable/enable scope
  - URLRequestBuilder: Remove unneeded synthesized initializer

All changes maintain thread safety and resolve Swift 6 strict concurrency
checking errors without suppressing warnings.
- Remove macos-10.15.yml (runner no longer available)
- Remove macos-11.yml (runner deprecated)
- Add macos-14.yml with Xcode 16.2 (supports Swift 6.1)
- Update ubuntu-latest.yml to use actions/checkout@v4
- Consolidate to single macOS workflow on latest available runner

macOS 14 is the oldest currently supported GitHub Actions runner.
Previous runners (macOS 10.15, 11, 13) have been deprecated or removed.
- Update README.md:
  - Fix workflow badges to reference new macos-14.yml
  - Remove outdated macos-10.15 and macos-11 badges

Documentation now accurately reflects the codebase state and breaking
changes introduced in this migration.
Remove Combine support and completion handler-based API in favor of async/await only. This simplifies the codebase and aligns with Swift 6.1 concurrency patterns.

BREAKING CHANGE: All completion handler methods and Combine publishers have been removed. Users must migrate to async/await patterns.
Replace wrapper-based async implementation with native URLSession async/await APIs. Remove URLServer+Task.swift helper file and inline necessary logic. Remove redundant Swift version guards and @available attributes since Swift 6.1 is now required.

Changes:
- Use urlSession.data(for:), urlSession.upload(for:fromFile:), and urlSession.download(for:) directly
- Inline buildRequest(endpoint:) and upload file detection
- Remove #if swift(>=5.5.2) guards
- Remove @available(macOS 10.15, iOS 13, ...) attributes
- Delete URLServer+Task.swift (trivial wrappers no longer needed)
- Update test mock signatures to async throws
Update Server and URLServer protocols to declare buildRequest as async throws, enabling async operations like token refresh, dynamic configuration, and rate limiting.

This addresses GitHub issue #105.
…namic headers

Add comprehensive tests showcasing async buildRequest functionality (addressing GitHub issue #105). Tests demonstrate:
- Dynamic header fetching with async configuration
- Token refresh pattern before request building

These tests serve as documentation for the async buildRequest feature.
Update package version to 2.0.0 and comprehensively document the async-only API changes.

Changes:
- Bump version to 2.0.0 in podspec
- Remove Combine weak_frameworks reference
- Add comprehensive migration guide in README
- Document async buildRequest examples and use cases
- Add CLAUDE.md with architecture documentation
- Update project description to emphasize Swift Concurrency

Migration guide covers:
- Completion handlers → async/await
- Combine → async/await with Task
- buildRequest signature changes
- Sendable requirements
- Add RequestConfiguring protocol with async configure method
- Add configuring parameter to all call methods in URLServer+Async
- Add configuring parameter to download method in URLServer+Download
- Add RequestConfiguringTests demonstrating authorization use case

This enables use cases like:
- Adding authorization headers dynamically
- Token refresh before request execution
- Per-request rate limiting

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Resolve conflicts favoring our branch. Remove files main brought back
that were already deleted (Combine/, Templates/, ResponseTests).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@jmarek41 jmarek41 requested a review from ssestak March 17, 2026 15:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant