Community highlights
FAQ and Advice for Beginners - Please read before posting
What’s everyone working on this month? (November 2025)
What’s everyone working on this month? (April 2025)
Even though we just got 26.2 Beta, looks like Apple is already publishing some new instance methods coming up with iOS 26.4+Beta, iPadOS 26.4+Beta, Mac Catalyst 26.4+Beta, macOS 26.4+Beta, tvOS 26.4+Beta, visionOS 26.4+Beta and watchOS 26.4+Beta.
It’s a new overload of .task that adds:
name: — a human-readable label that shows up in debugging/profiling so you can tell tasks apart.
executorPreference: — an advanced hook to request a particular executor for the task hierarchy (for folks using custom executors).
Still supports priority: and id: (the id causes the task to restart when the value changes).
Debuggability: name makes async work much easier to trace in instruments/logs.
Control (advanced): executorPreference is there if you need to steer where non-isolated async work runs.
Familiar lifecycle: Same start/cancel behavior as the existing .task.
Like other .task variants, it starts just before the view appears and is automatically cancelled when the view disappears.
I have a command line app that I what to port to Linux from macOS. It has a few features that use AppKit (NSImage for example) that are not supported on Linux.
Is there a way to custom compile to avoid those features. on Linux but still have them on macOS? As its only a small part of the application, I'd like not to have to have two separate code bases
For example is there any in-source means to only import AppKit and use NSImage on build on macOS, perhaps with if #available(...)
However, it seems I can't do this at the top-level
import Foundationif #available(macOS 10.0, *) { import AppKit}Then I was then hoping to use if in functions, but it not working how I wanted for example...
if #available(macOS 10.0, *) { // I wanted this to run only for macOS, but... print("This gets printed on Linux and macOS") } else { print("This never prints") }Seems #available(...) is always true on Linux, or I'm doing this wrong
Or, maybe there is a way to leverage the SPM to build with different source files depending on the platform? I'm quite new to SPM and I think I'm struggling to find the right set of words to google for platform dependent building


