I have a project I've been preparing for Swift6 and the complete concurrency checking. As of beta 3 I had everything compiling and running ok but as soon as I've installed beta 4 I'm unable to build the project using Swift6 mode (it still compiles and runs on Swift5 mode).
I don't see any clue on what the problem might be (I'm guessing the compiler is choking on some piece of code somewhere) and the logs don't help. All I see is the SwiftCompile command with all its parameters and a huge list of swift files. No specific error message. I also don't see anything on the console's crash reports.
Any clues how to get more info? Should I file a bug? I'm not sure how that can be helpful without any other information to share about the problem...
Or maybe I should just wait and see if this is fixed by next beta...
Edit: I've tried all the usual fixes such as clean build and deleting the derived data folder and resetting packages caches
Update: I've located the problem file and the problem line:
try await exporter.export(to: destinationURL, as: AVFileType.m4a)
Commenting that line removes the error and the project compiles fine. I had that inside an if
#available
(iOS 18, *) clause that reverted to the old (now deprecated) export() for iOS17 and below.
If you'll go to report navigator on the left panel (the last one icon there) and open failed build logs, you can find the log with this error like that:
By tap on this "hamburger" on the right side, you can expand actual error that caused this (you will need to scroll through the build command first to get to actual stack dump). It will then help to understand what's wrong (might be a compiler bug, for example).
Thanks. I can't find anything resembling an error on that text. It's basically a line starting with "SwiftCompile normal arm64..." and ending with "(in target 'TargetName' from project 'ProjectName)". Then another line with a cd command and then a huge line starting with "builtin-swiftTaskExecuion -- /path/to/swift-frontent -c -filelist" and a huge list of paths to different files ending with "-index-system-modules". Nothing like an actual error message in there...
Maybe there is another one "hamburger"? Sometimes Xcode (50% times, actually) goes nuts and gives you something like that:
And one of these have only information you mention, but another have more detailed logs. I'm more often than not finally manage to retrieve stack dump out of there, but it might not be from the first try.
You can also try run
xcodebuild
command from console by yourself, there at least Xcode's UI won't be an issue.
As last alternative, if possible, try to isolate code that you can suspect to cause an error (I think probably something migrated to new concurrency, especially if it uses region-based isolation or dynamic isolation – that's top from my experience that causes crashes for compiler right now).
No luck... There's no second hamburger menu and building using the terminal gives me exactly the same output with just the generic "Command SwiftCompile failed with a nonzero exit code"
Thanks for the help! I'll try to isolate possible code that may cause the issue. It's going to take a while but unless this is fixed on the next beta it looks like the only solution...
### Reproduction
I am seeing this crash while using the workaround from https
…
://github.com/swiftlang/swift/issues/74609. Here are my current steps to repro:
1. Create a Swift Package.
2. Declare a `Repeater` variadic type in one file:
```swift
fileprivate struct FnBox<T> {
let fn: () -> T
struct Repeater<each Element> {
private let _elements: (repeat FnBox<each Element>)
var elements: (repeat () -> each Element) {
return (repeat (each _elements).fn)
init(elements element: repeat @escaping () -> each Element) {
self._elements = (repeat FnBox(fn: each element))
3. Declare a `Repeater` extension in a different file:
```swift
extension Repeater {
func printElements() {
print((repeat (each self.elements)()))
This leads to a compiler crash. I see the compiler crash when `FnBox` is `fileprivate` or `private`.
There seem to be (at least) three workarounds:
1. Declare the `elements` tuple directly as a parameter pack of closures without the `FnBox` helper:
```swift
struct Repeater<each Element> {
var elements: (repeat () -> each Element)
This is suboptimal. The reason I want the workaround from https://github.com/swiftlang/swift/issues/74609 is because of a compiler crash from 5.10.
2. Declare the `Repeater` extension in the same file. This might not be an available option for my use-case.
3. Declare the `FnBox` helper to be `internal`:
```swift
internal struct FnBox<T> {
let fn: () -> T
### Stack dump
```text
Global is external, but doesn't have external or weak linkage!
ptr @"$s9MyLibrary5FnBox33_4A6444129A9675BDC10B0CBB9EC84AB1LLVMa"
Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the crash backtrace.
Stack dump:
0. Program arguments: /Applications/Xcode_16_beta_3.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-frontend -frontend -c /Users/rick/Desktop/MyLibrary/Sources/MyLibrary/MyLibrary.swift -primary-file /Users/rick/Desktop/MyLibrary/Sources/MyLibrary/Repeater.swift -emit-dependencies-path /Users/rick/Library/Developer/Xcode/DerivedData/MyLibrary-fszgispmxfgjgmfpdyjlofjzlfuf/Build/Intermediates.noindex/MyLibrary.build/Debug/MyLibrary.build/Objects-normal/arm64/Repeater.d -emit-const-values-path /Users/rick/Library/Developer/Xcode/DerivedData/MyLibrary-fszgispmxfgjgmfpdyjlofjzlfuf/Build/Intermediates.noindex/MyLibrary.build/Debug/MyLibrary.build/Objects-normal/arm64/Repeater.swiftconstvalues -emit-reference-dependencies-path /Users/rick/Library/Developer/Xcode/DerivedData/MyLibrary-fszgispmxfgjgmfpdyjlofjzlfuf/Build/Intermediates.noindex/MyLibrary.build/Debug/MyLibrary.build/Objects-normal/arm64/Repeater.swiftdeps -serialize-diagnostics-path /Users/rick/Library/Developer/Xcode/DerivedData/MyLibrary-fszgispmxfgjgmfpdyjlofjzlfuf/Build/Intermediates.noindex/MyLibrary.build/Debug/MyLibrary.build/Objects-normal/arm64/Repeater.dia -target arm64-apple-macos15.0 -Xllvm -aarch64-use-tbi -enable-objc-interop -stack-check -sdk /Applications/Xcode_16_beta_3.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.0.sdk -I /Users/rick/Library/Developer/Xcode/DerivedData/MyLibrary-fszgispmxfgjgmfpdyjlofjzlfuf/Build/Products/Debug -I /Applications/Xcode_16_beta_3.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/lib -F /Users/rick/Library/Developer/Xcode/DerivedData/MyLibrary-fszgispmxfgjgmfpdyjlofjzlfuf/Build/Products/Debug -F /Applications/Xcode_16_beta_3.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks -no-color-diagnostics -enable-testing -g -debug-info-format=dwarf -dwarf-version=5 -module-cache-path /Users/rick/Library/Developer/Xcode/DerivedData/ModuleCache.noindex -profile-generate -profile-coverage-mapping -swift-version 6 -enforce-exclusivity=checked -Onone -D SWIFT_PACKAGE -D DEBUG -D Xcode -serialize-debugging-options -enable-experimental-opaque-type-erasure -const-gather-protocols-file /Users/rick/Library/Developer/Xcode/DerivedData/MyLibrary-fszgispmxfgjgmfpdyjlofjzlfuf/Build/Intermediates.noindex/MyLibrary.build/Debug/MyLibrary.build/Objects-normal/arm64/MyLibrary_const_extract_protocols.json -enable-experimental-feature DebugDescriptionMacro -empty-abi-descriptor -plugin-path /Applications/Xcode_16_beta_3.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/host/plugins/testing -validate-clang-modules-once -clang-build-session-file /Users/rick/Library/Developer/Xcode/DerivedData/ModuleCache.noindex/Session.modulevalidation -Xcc -working-directory -Xcc /Users/rick/Desktop/MyLibrary/.swiftpm/xcode -resource-dir /Applications/Xcode_16_beta_3.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift -enable-anonymous-context-mangled-names -file-compilation-dir /Users/rick/Desktop/MyLibrary/.swiftpm/xcode -Xcc -ivfsstatcache -Xcc /Users/rick/Library/Developer/Xcode/DerivedData/SDKStatCaches.noindex/macosx15.0-24A5289c-340415df322634e4d06d2a80bf8f7b40.sdkstatcache -Xcc -I/Users/rick/Library/Developer/Xcode/DerivedData/MyLibrary-fszgispmxfgjgmfpdyjlofjzlfuf/Build/Intermediates.noindex/MyLibrary.build/Debug/MyLibrary.build/swift-overrides.hmap -Xcc -I/Users/rick/Library/Developer/Xcode/DerivedData/MyLibrary-fszgispmxfgjgmfpdyjlofjzlfuf/Build/Products/Debug/include -Xcc -I/Users/rick/Library/Developer/Xcode/DerivedData/MyLibrary-fszgispmxfgjgmfpdyjlofjzlfuf/Build/Intermediates.noindex/MyLibrary.build/Debug/MyLibrary.build/DerivedSources-normal/arm64 -Xcc -I/Users/rick/Library/Developer/Xcode/DerivedData/MyLibrary-fszgispmxfgjgmfpdyjlofjzlfuf/Build/Intermediates.noindex/MyLibrary.build/Debug/MyLibrary.build/DerivedSources/arm64 -Xcc -I/Users/rick/Library/Developer/Xcode/DerivedData/MyLibrary-fszgispmxfgjgmfpdyjlofjzlfuf/Build/Intermediates.noindex/MyLibrary.build/Debug/MyLibrary.build/DerivedSources -Xcc -DSWIFT_PACKAGE -Xcc -DDEBUG=1 -module-name MyLibrary -package-name mylibrary -frontend-parseable-output -disable-clang-spi -target-sdk-version 15.0 -target-sdk-name macosx15.0 -external-plugin-path /Applications/Xcode_16_beta_3.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/lib/swift/host/plugins#/Applications/Xcode_16_beta_3.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/bin/swift-plugin-server -external-plugin-path /Applications/Xcode_16_beta_3.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/local/lib/swift/host/plugins#/Applications/Xcode_16_beta_3.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/bin/swift-plugin-server -plugin-path /Applications/Xcode_16_beta_3.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/host/plugins -plugin-path /Applications/Xcode_16_beta_3.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/local/lib/swift/host/plugins -o /Users/rick/Library/Developer/Xcode/DerivedData/MyLibrary-fszgispmxfgjgmfpdyjlofjzlfuf/Build/Intermediates.noindex/MyLibrary.build/Debug/MyLibrary.build/Objects-normal/arm64/Repeater.o -index-unit-output-path /MyLibrary.build/Debug/MyLibrary.build/Objects-normal/arm64/Repeater.o -index-store-path /Users/rick/Library/Developer/Xcode/DerivedData/MyLibrary-fszgispmxfgjgmfpdyjlofjzlfuf/Index.noindex/DataStore -index-system-modules
1. Apple Swift version 6.0 (swiftlang-6.0.0.5.15 clang-1600.0.22.6)
2. Compiling with the current language version
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
0 swift-frontend 0x000000010623dda8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 56
1 swift-frontend 0x000000010623bffc llvm::sys::RunSignalHandlers() + 112
2 swift-frontend 0x000000010623e374 SignalHandler(int) + 292
3 libsystem_platform.dylib 0x000000019fee7584 _sigtramp + 56
4 libsystem_pthread.dylib 0x000000019feb6c20 pthread_kill + 288
5 libsystem_c.dylib 0x000000019fdc3a30 abort + 180
6 swift-frontend 0x0000000100c1076c PrettyStackTraceFrontend::~PrettyStackTraceFrontend() + 0
7 swift-frontend 0x00000001061ada7c llvm::report_fatal_error(llvm::Twine const&, bool) + 280
8 swift-frontend 0x00000001061ad964 llvm::report_fatal_error(llvm::Twine const&, bool) + 0
9 swift-frontend 0x00000001011f3d58 llvm::detail::PassModel<llvm::Module, llvm::VerifierPass, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::Module>>::printPipeline(llvm::raw_ostream&, llvm::function_ref<llvm::StringRef (llvm::StringRef)>) + 0
10 swift-frontend 0x0000000105f75fe0 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) + 224
11 swift-frontend 0x00000001011e8794 swift::performLLVMOptimizations(swift::IRGenOptions const&, llvm::Module*, llvm::TargetMachine*, llvm::raw_pwrite_stream*) + 3764
12 swift-frontend 0x00000001011ea3d0 swift::performLLVM(swift::IRGenOptions const&, swift::DiagnosticEngine&, llvm::sys::SmartMutex<false>*, llvm::GlobalVariable*, llvm::Module*, llvm::TargetMachine*, llvm::StringRef, llvm::vfs::OutputBackend&, swift::UnifiedStatsReporter*) + 2352
13 swift-frontend 0x0000000100c0ac9c generateCode(swift::CompilerInstance&, llvm::StringRef, llvm::Module*, llvm::GlobalVariable*) + 368
14 swift-frontend 0x0000000100c04fdc performCompileStepsPostSILGen(swift::CompilerInstance&, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule>>, llvm::PointerUnion<swift::ModuleDecl*, swift::SourceFile*>, swift::PrimarySpecificPaths const&, int&, swift::FrontendObserver*) + 2316
15 swift-frontend 0x0000000100c03e3c swift::performCompileStepsPostSema(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 984
16 swift-frontend 0x0000000100c0823c performCompile(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 1680
17 swift-frontend 0x0000000100c060e4 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 4280
18 swift-frontend 0x0000000100b8cc84 swift::mainEntry(int, char const**) + 3680
19 dyld 0x000000019fb2e0e0 start + 2360
### Environment
swift-driver version: 1.111.2 Apple Swift version 6.0 (swiftlang-6.0.0.5.15 clang-1600.0.22.6)
Target: arm64-apple-macosx14.0
Thanks. I see nothing like a stack dump. It's just the command with all the parameters and options. Edit: In fact I can copy the whole command and run it in the terminal. And it doesn't produce anything I can identify as an error/crash. It's only when building (either on XCode or with xcodebuild) that the failure is reported, but nothing more
Edit: I've updated the first post. Commenting the line "try? await exporter.export(to: destinationURL, as: AVFileType.m4a)" fixes the compiler error.
I've tried to copy my function to a new project and it compiles fine. It also gives me a warning about the function status from AVAssetExportSession being deprecated and to use progressStates(updateInterval:) for which I find no documentation and XCode won't recognise it. I guess it's not ready yet...
It's strange that this code compiles fine under beta 3 and also using Swift5 mode with beta4. I'll file a bug but I'm guessing this should be fixed as we get near the final release...
This is the function (from a NSObject
@MainActor
class)
func convert(sourceURL: URL, destinationURL: URL, success: ( @Sendable ()->Void)?, failure: ( @Sendable ()->Void)? ) {
Task {
let started = now()
print("started \(started)")
let asset = AVURLAsset(url: sourceURL)
if let exporter = AVAssetExportSession(asset: asset, presetName: AVAssetExportPresetAppleM4A) {
if #available(iOS 18, *) {
try? await exporter.export(to: destinationURL, as: AVFileType.m4a)
} else {
exporter.outputFileType = AVFileType.m4a
exporter.outputURL = destinationURL
await exporter.export()
switch exporter.status {
case .failed:
print("failed \(exporter.error.debugDescription)")
if let c = failure {
case .cancelled:
print("cancelled \(exporter.error.debugDescription)")
if let c = failure {
default:
print("complete")
if let c = success {
Edit: removed the line "let e = exporter". I had to add it or else XCode 16 beta 3 would complain (a bug I guess). This is no longer a problem in Beta 4