Adventures in Advent of Code
&gt; The bug is fixed in Swift 5.7, but my computer is running macOS Monterey (12.6) and thus using an earlier version of Swift. I have since confirmed that the code works as expected on macOS Ventura.<p>I guess the bug is apparently in the Swift runtime itself, and since Swift 5.0 and ABT stability, the runtime version is tied to the OS version.<p><a href="https:&#x2F;&#x2F;www.swift.org&#x2F;blog&#x2F;abi-stability-and-apple&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.swift.org&#x2F;blog&#x2F;abi-stability-and-apple&#x2F;</a><p>But I think that only applies to deployments via the App Store. I think for local development you can run against the current runtime by setting the TOOLCHAINS environment variable (you may also need to set SDKROOT).<p><a href="https:&#x2F;&#x2F;www.swift.org&#x2F;getting-started&#x2F;#on-macos" rel="nofollow">https:&#x2F;&#x2F;www.swift.org&#x2F;getting-started&#x2F;#on-macos</a><p>ETA. Apple does not make it easy to replace the runtime, but I got it to work like this:<p><pre><code>    $ sw_vers
    ProductName: macOS
    ProductVersion: 12.6
    BuildVersion: 21G115
    
    $ cat foo.swift
    let a = &quot;gnmCjzwnmCPTPhBwPjzBgqPjllJJSWlhfhQDSrpJRhDSlfJl&quot;
    let b = &quot;rLHNHrLHVNbVHMMctZFHsbcsDSDWpSDSGfSRsRWSRllfGSSG&quot;
    let c = &quot;NNtdMVrLNdZNvLvLZrzCndqBgwwPmwgjggBn&quot;
    
    var s1 = Set(a)
    s1.formIntersection(b)
    s1.formIntersection(c)
    print(s1)
    
    var s2 = Set(a)
    s2.formIntersection(Set(b))
    s2.formIntersection(Set(c))
    print(s2)
    
    $ swiftc -version
    swift-driver version: 1.62.15 Apple Swift version 5.7.1 (swiftlang-5.7.1.135.3 clang-1400.0.29.51)
    Target: arm64-apple-macosx12.0
    
    $ swiftc foo.swift
    $ .&#x2F;foo
    [&quot;P&quot;, &quot;r&quot;, &quot;C&quot;, &quot;z&quot;, &quot;w&quot;, &quot;m&quot;, &quot;B&quot;, &quot;q&quot;, &quot;j&quot;, &quot;g&quot;, &quot;n&quot;]
    [&quot;r&quot;]
    
    $ otool -L foo
    foo:
     &#x2F;usr&#x2F;lib&#x2F;libobjc.A.dylib (compatibility version 1.0.0, current version 228.0.0)
     &#x2F;usr&#x2F;lib&#x2F;libSystem.B.dylib (compatibility version 1.0.0, current version 1319.0.0)
     &#x2F;usr&#x2F;lib&#x2F;swift&#x2F;libswiftCore.dylib (compatibility version 1.0.0, current version 
    $ DYLD_LIBRARY_PATH=&#x2F;Library&#x2F;Developer&#x2F;Toolchains&#x2F;swift-5.7.1-RELEASE.xctoolchain&#x2F;usr&#x2F;lib&#x2F;swift&#x2F;macosx .&#x2F;foo
    [&quot;r&quot;]
    [&quot;r&quot;]
</code></pre>
Note that I had to download and install Swift 5.7.1 from swift.org. Trying to use libswiftCore.dylib from Xcode-14.1 is no bueno:<p><pre><code>    $ &#x2F;Applications&#x2F;Xcode.app&#x2F;Contents&#x2F;Developer&#x2F;usr&#x2F;bin&#x2F;xcodebuild -version
    Xcode 14.1
    Build version 14B47b
    $ DYLD_LIBRARY_PATH=&#x2F;Applications&#x2F;Xcode.app&#x2F;Contents&#x2F;Developer&#x2F;Toolchains&#x2F;XcodeDefault.xctoolchain&#x2F;usr&#x2F;lib&#x2F;swift&#x2F;macosx .&#x2F;foo
    [&quot;B&quot;, &quot;P&quot;, &quot;q&quot;, &quot;C&quot;, &quot;r&quot;, &quot;n&quot;, &quot;j&quot;, &quot;w&quot;, &quot;m&quot;, &quot;z&quot;, &quot;g&quot;]
    [&quot;r&quot;]
</code></pre>
Oh, it&#x27;s because &#x2F;Applications&#x2F;Xcode.app&#x2F;Contents&#x2F;Developer&#x2F;Toolchains&#x2F;XcodeDefault.xctoolchain&#x2F;usr&#x2F;lib&#x2F;swift-5.0&#x2F;macosx&#x2F;libswiftCore.dylib is x86_64 only for some reason and I&#x27;m testing on an MBA M1.<p>The dylibs under &#x2F;Library&#x2F;Developer&#x2F;Toolchains&#x2F;swift-5.7.1-RELEASE.xctoolchain&#x2F;usr&#x2F;lib&#x2F;swift&#x2F;macosx are arm64 and x86_64.<p>WTF Apple?