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
Static building isn't supported on new versions of MacOS. See answer here :
https://forums.swift.org/t/swift-package-manager-static-build-failing-after-software-updates/25694