Trying to build and run a Swift Package Executable in Jenkins and running into an issue with linking Foundation.
13:25:36 [1374/1378] Compiling MyMockServer Environment.swift
13:25:36 [1375/1378] Compiling MyMockServer Shell.swift
13:25:36 [1376/1378] Compiling MyMockServer main.swift
13:25:36 [1377/1378] Emitting module MyMockServer
13:25:36 [1377/1378] Linking MyMockServer
13:25:36 Build complete! (80.93s)
13:25:38 [0/1] Planning build
13:25:38 Building for debugging...
13:25:38 Build complete! (0.73s)
13:25:38 dyld[1185]: Symbol not found (_$s10Foundation11JSONDecoderC19KeyDecodingStrategyOMa)
13:25:38 Referenced from: '/private/var/jenkins/workspace/myPR/iOS/Frameworks/Packages/MyMockServer/.build/x86_64-apple-macosx/debug/MyMockServer'
13:25:38 Expected in: '/System/Library/Frameworks/Foundation.framework/Versions/C/Foundation'
Here was what the package.swift file looks like
// swift-tools-version: 5.7.1
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription
let package = Package(
name: "MyMockServer",
platforms: [.macOS(.v13)],
products: [
.executable(
name: "MyMockServer",
targets: ["MyMockServer"]),
],
dependencies: [
.package(url: "https://github.com/vapor/vapor", from: "4.7.0")
],
targets: [
.executableTarget(
name: "MyMockServer",
dependencies: [
.product(name: "Vapor", package: "vapor")
]
)
]
)
And here is the Jenkinsfile call site
# Start MyMockServer
cd ../iOS/Frameworks/Packages/MyMockServer
swift build
swift run
I understand that Foundation is linked dynamically and this can cause issues like discussed in this thread (Problem call from the Jenkins pipeline "undefined symbol: _T0SS10FoundationE11capitalizedSSfg" · Issue #2026 · realm/SwiftLint · GitHub) However the solution mentioned was to re-build from scratch every time, which is what is being done here. Is this an issue with my package.swift file or am I missing a step in building and running the package?