Migrate to Swift 6 language mode - #65
Open
LucijaUlaga wants to merge 2 commits into
Open
LucijaUlaga wants to merge 2 commits into
LucijaUlaga wants to merge 2 commits into
Conversation
Build every target in the Swift 6 language mode and resolve the strict concurrency diagnostics it surfaces. No async/await or actors are introduced; the library work is Sendable annotation only. - Raise the floor to iOS 12 / macOS 10.13, the oldest versions the 6.0 toolchain still accepts. - Conform JapxEncoder, JapxDecoder and both Options types to Sendable, and document the precondition the two coder wrappers rely on. - Box the parsed dictionary in JSONAPIDocument, since Alamofire requires a response serializer's SerializedObject to be Sendable and [String: Any] cannot be. This changes the type responseJSONAPI hands back; subscripting is forwarded, so reading a single key is unchanged. The initializer is internal to keep the unchecked conformance sound. - Mark the four Alamofire wrappers @preconcurrency, matching the Alamofire API they wrap, so a non-Sendable capture at a call site stays a warning instead of becoming an error. - Require T: Decodable & Sendable on the codable response helpers. - Declare the RxSwift ReactiveCompatible conformances @retroactive, and use nonisolated(unsafe) for the observers, with a note to remove it once RxSwift annotates them. - Isolate the example app's Resultable extension to @mainactor. - Bump to 5.0.0. The response type change, the new Sendable requirement and the platform floor are all source-breaking.
The podspec floor moved to iOS 12 with the Swift 6 migration, but the
example's Podfile still declared iOS 10, so a fresh `pod install` failed
resolution before installing anything:
[!] CocoaPods could not find compatible versions for pod "Japx/ObjC":
Specs satisfying the dependency were found, but they required a
higher minimum deployment target.
An existing checkout kept working off its already-installed Pods, so this
only bit a clean clone — which is exactly what the README tells people to
do. Regenerates the lockfile on 5.0.0.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Builds every target in the Swift 6 language mode and resolves the strict concurrency diagnostics it surfaces. No async/await or actors are introduced — the library work is
Sendableannotation only.Breaking changes
responseJSONAPIcompletions now receiveAFDataResponse<JSONAPIDocument>instead ofAFDataResponse<Japx.Parameters>. Alamofire requires a response serializer'sSerializedObjectto beSendable, which[String: Any]cannot be.JSONAPIDocumentforwards subscripts, soresponse.value?["data"]is unchanged;.dictionarygives the whole thing. The.rxvariants still emitSingle<Japx.Parameters>.responseCodableJSONAPIrequiresT: Decodable & Sendable. Structs and enums get this for free; non-finalclasses need their own conformance..v10/.v10_12. Nothing here needs an iOS 12 runtime.README has a "Migrating to 5.0" section covering all three.
Notable choices
@preconcurrency, mirroring the attribute on Alamofire's ownresponse(queue:responseSerializer:completionHandler:). Without it Japx is stricter than the API it wraps: a non-Sendablecapture at a call site is a hard error through Japx but only a warning throughresponseDecodable.JSONAPIDocument.initis internal — the serializer is the only producer, which is what keeps its@unchecked Sendableconformance sound.JapxErrorkeeps itsAnypayloads. The doc comment was narrowed instead: the no-mutation guarantee holds for theData-based entry points, but forjsonObject(withJSONAPIObject:)/encode(json:)the payload aliases the caller's own collection.nonisolated(unsafe), with a TODO to remove it once RxSwift annotates its observer closures.