Swift Package manager : static build failing after software updates

Problem Description

One project I'm working on isn't building since I updated Xcode.
Note that I am building the exécutable with swift build (not Xcode).

Details

The command that is failing is :
swift build -Xswiftc -static-stdlib -Xswiftc -DDEBUG

I am trying to make a static build. When just try swift build, it works.

The error

I'm copying the beginning of the error output only (the rest is too long):

ld: warning: directory not found for option '-L/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift_static/macosx'
ld: warning: Could not find auto-linked library 'swiftFoundation'
ld: warning: Could not find auto-linked library 'swiftDarwin'
ld: warning: Could not find auto-linked library 'swiftCoreFoundation'
ld: warning: Could not find auto-linked library 'swiftIOKit'
ld: warning: Could not find auto-linked library 'swiftQuartzCore'
ld: warning: Could not find auto-linked library 'swiftCore'
ld: warning: Could not find auto-linked library 'swiftCoreGraphics'
ld: warning: Could not find auto-linked library 'swiftObjectiveC'
ld: warning: Could not find auto-linked library 'swiftDispatch'
ld: warning: Could not find auto-linked library 'swiftCoreData'
ld: warning: Could not find auto-linked library 'swiftSwiftOnoneSupport'
ld: warning: Could not find auto-linked library 'swiftXPC'
ld: warning: Could not find auto-linked library 'swiftMetal'
ld: warning: Could not find auto-linked library 'swiftAppKit'
ld: warning: Could not find auto-linked library 'swiftCoreImage'
Undefined symbols for architecture x86_64:

Package.swift

Note that I've renamed the project and library names for anonymity.

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

import PackageDescription

let package = Package(
    name: "PROJECT",
    dependencies: [
        // Dependencies declare other packages that this package depends on.
        // .package(url: /* package url */, from: "1.0.0"),
        .package(url: "../Lib1", .branch("master")),
        .package(url: "../Lib2", .branch("master")),
        .package(url: "../Lib3", .branch("master")),
        .package(url: "../Lib4", .branch("master")),
    ],
    targets: [
        // Targets are the basic building blocks of a package. A target can define a module or a test suite.
        // Targets can depend on other targets in this package, and on products in packages which this package depends on.
        .target(
            name: "PROJECT",
            dependencies: ["Lib1", "Lib2", "Lib3", "Lib4"]),
    ]
)

Swift version after update

Running

swift -version

in the command line returns :

Apple Swift version 5.0 (swiftlang-1001.0.69.5 clang-1001.0.46.3)
Target: x86_64-apple-darwin18.2.0

Hi, @kmn. Swift does not support -static-stdlib on Apple platforms anymore; see the discussion in Command line applications crashes with Xcode 10.2. I am a little surprised you didn't see an error message about that, though.

Is the compiler checking for this flag? We do diagnose this in SwiftPM but not when it's directly passed to the compiler using -Xswiftc.

Oops, you're right. I didn't realize we didn't diagnose this on the compiler side [yet?].

Looks like this should error now https://github.com/apple/swift/blob/9b635833cce6aec0f8bea9b8eb0a271eec5187d8/lib/Driver/DarwinToolChains.cpp#L627-L630

Terms of Service

Privacy Policy

Cookie Policy