Post

Replies

Boosts

Views

Activity

Reply to Differences between SwiftUI in Monterey and Sequoia
Thanks for those ideas. Now for a harder case, in which I need to do something of the form: var body: some Scene { if #available(macOS 13.0, *) { WindowGroup { AppView() } .defaultSize(CGSize(width: w, height :h)) .defaultPosition(UnitPoint(x: x, y: y)) } else { WindowGroup { AppView() } } } A SceneBuilder doesn't accept a control flow statement in its closure (like View does - your example earlier) var body: some Scene { WindowGroup { AppView() } if #available(macOS 13.0, *) { .defaultSize(CGSize(width: w, height :h)) .defaultPosition(UnitPoint(x: x, y: y)) } } Were this a View I could perform the platform conditional in a View extension using a ViewModifier to but there's no SceneModifier equivalent. My high-level challenge is to write a SwiftUI app that runs in macOS from Monterey to Sequoia, hence the need to condition out features missing in earlier generations.
Topic: UI Frameworks SubTopic: SwiftUI
Jan ’25
Reply to Network Framework
As often happens, writing a question drove me to find my own answer. In this case, I wrote a sample using the new class "NetworkConnection" and (a) the documentation shows up in Xcode and (b) the new capabilities are not available before xOS 26.
Jun ’25
Reply to Network Framework
To be honest, what I (and others) have wanted is concurrency in NWConnection I've provided that for myself, with suggestions from this Forum, with the following: extension NWConnection { func asyncSend(data: Data?) async throws { try await withCheckedThrowingContinuation { (continuation: CheckedContinuation<Void, Error>) in send(content: data, completion: .contentProcessed { error in if let error { continuation.resume(throwing: error) } else { continuation.resume(returning: ()) } }) } } func asyncReceive(length: Int) async throws -> Data { try await withCheckedThrowingContinuation { continuation in receive(minimumIncompleteLength: length, maximumLength: length) { data, _, connectionEnded, error in if connectionEnded { logger.log("←→ connection did end") continuation.resume(throwing: NWError.posix(.ECONNRESET)) } else if let error { continuation.resume(throwing: error) } else { continuation.resume(returning: data ?? Data(repeating: 0, count: 4)) } } } } } The significantly increased power and sophistication in NetworkConnection is welcome but my app's networking (with the above Extension) works from Monterey onwards. I will file a request in Feedback Assistant .. in fact, I'll file two! One to enhance NWConnection to support async and the other to have NetworkConnection operate in current, and older, systems. [ FB17963806 ]
Jun ’25