Apple has released version 6.0 of the Swift language – coinciding with the general availability of macOS 15 and iOS/iPadOS 18 – with a host of improvements including safer concurrency, a new standard testing library, and wider cross-platform support across Linux and Windows as well as Apple platforms.
Swift is a compiled language with performance close to that of C or C++, but safer and more approachable for developers. Safety features include that variables must be initialized before use, overflow checks apply to arrays and integers, memory management is automatic, and by default objects can never be nil (equivalent to null).
In Swift 6, there is a new opt-in mode which makes concurrent programming safer too, by means of compiler checks that detect data race bugs as errors. A data race occurs when two or more threads access the same memory location, with unpredictable results. The safety feature is described in the release announcement as “the start of the journey” and “an area of active development.” The reason for the hesitation is the risk of false positives that prevent good code from compiling, as well as the possibility of missing some bugs.
Another key new feature is the introduction of a standard testing framework, called Swift Testing. This means that developers can simply add “import Testing” to their test code with no need to add further dependencies.
C++ interoperability is improved with support for more C++ types, virtual methods, and more. This is important as it eases the process of migrating to Swift for developers with existing codebases, enabling new code to be written in Swift.
Other new features include 128-bit integer types. the ability to specify the type of exception that a function throws, support for non-copyable types in generic code, and a preview of Embedded Swift, for targets such as microcontrollers.
Both Apple and the open source Swift community are working to extend the number of supported platforms, which now include Apple’s own Mac and device platforms, Windows 10 and higher (both x86 and Arm), Ubuntu, CentOS 7, Amazon Linux 2, Red Hat 9, Debian and Fedora. There is no support yet for Amazon Linux 2023, which has superseded Amazon Linux 2.
Targeting Linux for server-side applications is easier in Swift 6, thanks to the addition of the static SDK for Linux – for compiling on macOS or Windows, for example, while targeting Linux. Using static compilation also eliminates most compatibility problems, at the cost of higher memory usage and larger executables.
Another key feature for cross-platform is that the Foundation library, providing core functionality, is now written in Swift and the same across all platforms – completing a project that began in December 2022.
Can Swift shake off its Apple-only image?
The matter of cross-platform support touches on the wider question of whether Swift will fully escape its Apple platform niche to become mainstream. In principle it has some of the attractions of a language such as Rust – including native compilation and memory safety – but is easier to learn and use.
The evidence so far is that Swift remains in its niche. Language stats for GitHub repositories, for example, suggest that Swift usage has actually declined – from 1.75 percent in 2016 to 1.08 percent in 2024 – though this is by no means a comprehensive indicator of usage.
The push for cross-platform may improve adoption. The challenge is that Apple will always primarily invest in Swift for its own platforms, rather than for cross-platform – and the programming community is mostly not yet convinced of the language’s cross-platform potential.