'Swift Package Manager dependencies won't build: "Showing All Errors Only Command CompileSwiftSources failed with a nonzero exit code"
For some reason whenever I try to update my dependencies through SPM I get build errors. Others on my team can fetch fine, for some reason I have a hexed machine. Same version of macOS, same version of XCode, same branch from git.
FYI macOS Monterey 12.3.1 XCode 13.2.1
- I'm downloading 13.3.1 as I type this.
Here are the steps I've used to try to fix this problem. I went full scorched earth since I'm desperate.
- closed Xcode
- cloned new repo from Git
- deleted derived data
- went into the workspace and cleared package.resolve
- I've had problems where the package resolve was messed up from someone else's check-in
- I've tried not clearing the package.resolve with the same result
- cd into project directory in the terminal
- fetched dependencies through command line
xcodebuild -resolvePackageDependencies -scheme *schemeName* -project *project*.xcodeproj -configuration Debug
- I've also done this through xcode but this often times gets stuck.
After I've done the following I'll open XCode and try to run and I'm met with the same errors.
Here's the build log:
Build target *InternalOBJCFramework* with configuration Debug
*removed*
Undefined symbols for architecture arm64:
"___llvm_profile_runtime", referenced from:
___llvm_profile_runtime_user in *InternalOBJCFramework*.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Build target Socket with configuration Debug
CompileSwiftSources normal arm64 com.apple.xcode.tools.swift.compiler (in target 'Socket' from project 'Socket')
*removed*
Command CompileSwiftSources failed with a nonzero exit code
Build target KeychainAccess with configuration Debug
CompileSwiftSources normal arm64 com.apple.xcode.tools.swift.compiler (in target 'KeychainAccess' from project 'KeychainAccess')
*removed*
error: jobFailedWithNonzeroExitCode(2, "")
Command CompileSwiftSources failed with a nonzero exit code
Build target BTree with configuration Debug
CompileSwiftSources normal arm64 com.apple.xcode.tools.swift.compiler (in target 'BTree' from project 'BTree')
*removed*
Command CompileSwiftSources failed with a nonzero exit code
Build target Rswift with configuration Debug
CompileSwiftSources normal arm64 com.apple.xcode.tools.swift.compiler (in target 'Rswift' from project 'R.swift.Library')
*removed*
Command CompileSwiftSources failed with a nonzero exit code
Build target CombineExt with configuration Debug
CompileSwiftSources normal arm64 com.apple.xcode.tools.swift.compiler (in target 'CombineExt' from project 'CombineExt')
*removed*
Command CompileSwiftSources failed with a nonzero exit code
Build target ReactiveSwift with configuration Debug
CompileSwiftSources normal arm64 com.apple.xcode.tools.swift.compiler (in target 'ReactiveSwift' from project 'ReactiveSwift')
*removed*
Command CompileSwiftSources failed with a nonzero exit code
Build target XCGLogger with configuration Debug
CompileSwiftSources normal arm64 com.apple.xcode.tools.swift.compiler (in target 'XCGLogger' from project 'XCGLogger')
*removed*
Command CompileSwiftSources failed with a nonzero exit code
Let's use SPM they said, it'll be easier they said. 🤦🏻♂️
Solution 1:[1]
The problem happened with a dependency I'm pulling in that had it's package.swift file define itself as being dynamic.
// inside the package.swift file
platforms: [.iOS(.v13)],
products: [
.library(
// changing this to name: "PrivateLib" and removing type: .dynamic fixed the issue
name: "PrivateLib", type: .dynamic,
targets: ["PrivateLib"]
)
],
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Biclops |