# Swift Package manager : static build failing after software updates

**URL:** <https://forums.swift.org/t/swift-package-manager-static-build-failing-after-software-updates/25694>\
**Category:** Using Swift\
**Tags:** packagemanager\
**Created:** [June 12, 2019, 10:51pm UTC](https://forums.swift.org/t/swift-package-manager-static-build-failing-after-software-updates/25694 "2019-06-12T22:51:08Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![kmn](https://avatars.discourse-cdn.com/v4/letter/k/6a8cbe/32.png) [@kmn](https://forums.swift.org/u/kmn)\
**Post date:** [June 12, 2019, 10:51pm UTC](https://forums.swift.org/t/swift-package-manager-static-build-failing-after-software-updates/25694/1 "2019-06-12T22:51:08Z")

</div>

**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

```

---

<div class="post-metadata">

**Author:** ![jrose](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/jrose/32/408_2.png) [@jrose](https://forums.swift.org/u/jrose)\
**Post date:** [June 12, 2019, 11:05pm UTC](https://forums.swift.org/t/swift-package-manager-static-build-failing-after-software-updates/25694/2 "2019-06-12T23:05:10Z")

</div>

Hi, @kmn. Swift does not support `-static-stdlib` on Apple platforms anymore; see the discussion in [Command line applications crashes with Xcode 10.2](https://forums.swift.org/t/command-line-applications-crashes-with-xcode-10-2/22192). I am a little surprised you didn't see an error message about that, though.

---

<div class="post-metadata">

**Author:** ![Aciid](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/aciid/32/429_2.png) [@Aciid](https://forums.swift.org/u/Aciid)\
**Post date:** [June 12, 2019, 11:57pm UTC](https://forums.swift.org/t/swift-package-manager-static-build-failing-after-software-updates/25694/3 "2019-06-12T23:57:32Z")

</div>

> [@jrose](#):
>
> 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`.

---

<div class="post-metadata">

**Author:** ![jrose](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/jrose/32/408_2.png) [@jrose](https://forums.swift.org/u/jrose)\
**Post date:** [June 13, 2019, 12:12am UTC](https://forums.swift.org/t/swift-package-manager-static-build-failing-after-software-updates/25694/4 "2019-06-13T00:12:40Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Keith](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/keith/32/291_2.png) [@Keith](https://forums.swift.org/u/Keith)\
**Post date:** [July 31, 2019, 4:16am UTC](https://forums.swift.org/t/swift-package-manager-static-build-failing-after-software-updates/25694/5 "2019-07-31T04:16:16Z")

</div>

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