"JIT session error: Symbols not found" when running swift command-line tool

Hi all,

I have a swift script that I've been running from the command line (macOS 12.4, Xcode 13.4.1) for a while with no issues.

I recently downloaded Xcode 14 beta 3 and the script no longer runs. It now fails with a "JIT session error: Symbols not found" error.

I can cut the script down to a very simple example

#!/usr/bin/swift

import Foundation

var url: URL = URL(fileURLWithPath: "/tmp")

I need to import Foundation to get access to the URL type for my script. Xcode 13.4.1 doesn't seem to need to do anything clever

% swift commandline-fail.swift
JIT session error: Symbols not found: [ _$s10Foundation3URLV15fileURLWithPathACSSh_tcfC, _$s10Foundation3URLVMa ]

Failed to materialize symbols: { (main, { __swift_FORCE_LOAD_$_swiftCoreFoundation_$_main, __swift_FORCE_LOAD_$_swiftDispatch_$_main, _$s4main3url10Foundation3URLVvp, __swift_FORCE_LOAD_$_swiftObjectiveC_$_main, __swift_FORCE_LOAD_$_swiftDarwin_$_main, _main, __swift_FORCE_LOAD_$_swiftXPC_$_main, __swift_FORCE_LOAD_$_swiftIOKit_$_main, ___swift_project_value_buffer, ___swift_allocate_value_buffer }) }

The failing swift version is

% swift --version 
swift-driver version: 1.60 Apple Swift version 5.7 (swiftlang-5.7.0.120.1 clang-1400.0.28.1)
Target: x86_64-apple-macosx12.0

This script runs fine using

% swift --version
swift-driver version: 1.45.2 Apple Swift version 5.6.1 (swiftlang-5.6.0.323.66 clang-1316.0.20.12)

Target: x86_64-apple-macosx12.0

Does anyone have any ideas how I can solve this issue? It looks like the JIT needs access to the Foundation library but I have no idea how to do this.

Cheers!

Replies

It seems to be a bug in Swift 5.7. We're using the below workaround

xcrun -sdk macosx swiftc YourScript.swift -o YourScript
YourScript [your additional arguments]