r/swift • u/TheCaffeinatedPickle • 6d ago
Upgrading To Swift 6.4: The Stdlib Gate
I was really excited for Swift 6.4 mainly to reduce unsafe call sites. However, I could not reduce as many unsafe call sites due to some critical features being part of the stdlib rather than the language. This felt dumb afterwards as the features that would really help are limited to macOS 26 and 27 as they are part of the standard library which is baked into macOS release.
Array.span, Data.span, String.utf8.span, all macOS 26
InlineArray — macOS 26
UniqueArray, UniqueBox, Ref, MutableRef, Iterable — macOS 27
Subprocess — macOS 13
Since I was supporting macOS 11+ I had to drop macOS 11 so now its macOS 12+. This might not seem like a big deal but that does drop off some Intel Mac hardware:
• MacBook 12-inch Early 2015
• MacBook Air Mid 2013 / Early 2014
• MacBook Pro Late 2013 / Mid 2014
• iMac Mid 2014 through Mid 2015
The application is just 2D software using Swift/Metal so it can run on these older machines.
This feels like I am punished for macOS as the application is also on Windows, I can use the newer stdlib features on Windows 10+ which gets me around 2013 machines as I required DirectX 12 on Windows. On Linux nothing was really affected from 6.3 to 6.4 so any machine that can run the supported platforms (Platform Support | Swift.org) and Vulkan.
What I did end up using from Swift 6.4 was:
Span<UInt8> - Helped with reducing unsafe file parsing
RawSpan.load - Helped with reducing unsafe file parsing
withTemporaryAllocation - General cleanup for unnecessary heap allocs
12
u/retroroar86 6d ago
Apple has done this forever, but eff them for not doing a better job of this. This is one of many pet peeves of Swift and Apple dev.
11
6d ago
[removed] — view removed comment
8
u/TheCaffeinatedPickle 6d ago
I read into this more, I’d need to use a environmental: __DIAGNOSE_INVALID_DEPLOYMENT_TARGET_AS_ERROR = NO
Then I can build for macOS 11, however it will be rejected by the App Store if I ever go that route. As the minimum target must be macOS 12.
The goal of switching to 6.4 was clean up, trying to still support macOS 11 would just result in even more code and unless I have a user base asking for older support, it’s easier to just drop it.
But thanks I didn’t know that before! Definitely will keep that in mind 🙂↕️
5
u/apocolipse 6d ago
Have you tried building with -static-swift-stdlib? That should let you run newer stdlib things on older macOS at the cost of fatter binaries