Symbol not found error after upgrading to XCode 10.2/Swift 5

I have a project managed by SPM which depends on Swift Syntax. Ever since upgrading to Swift 5/XCode 10.2.x I get this error when trying to run the executable:

dyld: Symbol not found: _$SBOWV
  Referenced from: <project build dir>/libSwiftSyntax.dylib
  Expected in:  /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/libswiftCore.dylib
in <project build dir>/libSwiftSyntax.dylib
Abort trap: 6

The dependancy is included in my Package.swift like so:

// swift-tools-version:5.0
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
    name: "MyPackage",
    dependencies: [
        .package(url: "https://github.com/apple/swift-syntax.git", .exact("0.50000.0")),
    ],
    targets: [
        .target(
            name: "MyExecutable",
            dependencies: ["SwiftSyntax"]),
    ]
    ...
}

So it looks like for some reason at runtime my executalble is unable to link to a separately compiled SwiftSyntax dynamic library which is not part of the XCode toolchain?

What is the recommended way to deal with this issue? I would like to keep my code platform independent as well if it makes a difference.

I think it is referencing your library instance. The library instance itself is referencing a system library and can't find the _$SBOWV external symbol in the external system library.

Have you re-compiled, re-built everything from scratch? You may have some object code, library binary code left over from pre-code Swift 5 that assumes the existence of this internal reference that no longer exists.

Thanks, you're right that seems to have been the problem. Recompiling the binary solved the problem.

Is it the case in general that Swift executables will be broken when the toolchain is updated?

I think the switch from Swift 4 to Swift 5 is somewhat a unique situation with the ABI stability guarantee that occurred in Swift 5. Whenever Swift gets module stability (Swift 6?), that may also introduce some upgrade issues for some. The Swift core team is doing an outstanding job (in my view!) planning these major transitions, however, there are always going to be some edge cases that slip through the cracks.

My general philosophy is if I see linker issues with system libraries, the best idea is to "clean the build folder, re-compile, and re-link." May even need to delete the DerivedData folder. All this assumes you are using Xcode. Goes for applications, your frameworks, and third-party frameworks you build from source.

Terms of Service

Privacy Policy

Cookie Policy