分段错误:11 xcode 12.4

Segmentation fault: 11 xcode 12.4

我们上周已将 xcode 版本 11.6 更新到 12.4。一切都运行良好。此次更新后,我们遇到了这个问题。我们尝试了这些步骤:

-clean / re-build
-removed derived data
-removed valid-archs from build settings
-added arm64 to Excluded Architectures
-reboot mac

我们仍然面临同样的问题。这些日志没有提供我们需要更改的 class 的正确信息。这些是我们尝试 运行 应用程序时收到的错误日志:

0 swift 0x000000010984e615 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 37
1 swift 0x000000010984d615 llvm::sys::RunSignalHandlers() + 85
2 swift 0x000000010984ebcf SignalHandler(int) + 111
3 libsystem_platform.dylib 0x00007fff70f0f5fd _sigtramp + 29
4 libsystem_platform.dylib 0x00007f8a8a354900 _sigtramp + 18446743571622286112
5 swift 0x00000001057c537b emitApplyArgument((anonymous namespace)::IRGenSILFunction&, 
swift::SILValue, swift::SILType, swift::irgen::Explosion&) + 283
6 swift 0x00000001057c441a (anonymous 
namespace)::IRGenSILFunction::visitFullApplySite(swift::FullApplySite) + 3770
7 swift 0x00000001057a2d26 swift::irgen::IRGenModule::emitSILFunction(swift::SILFunction*) + 8982
8 swift 0x000000010563b457 
swift::irgen::IRGenerator::emitGlobalTopLevel(llvm::StringSet<llvm::MallocAllocator>*) + 1607
9 swift 0x0000000105777c37 performIRGeneration(swift::IRGenOptions const&, swift::ModuleDecl, 
std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule> >, llvm::StringRef, 
swift::PrimarySpecificPaths const&, llvm::StringRef, swift::SourceFile, llvm::GlobalVariable*, 
llvm::StringSet<llvm::MallocAllocator>) + 1687
10 swift 0x00000001057a0781 swift::SimpleRequest<swift::IRGenSourceFileRequest, 
swift::GeneratedModule (swift::IRGenDescriptor), 
(swift::RequestFlags)9>::evaluateRequest(swift::IRGenSourceFileRequest const&, swift::Evaluator&) + 
97
11 swift 0x000000010577c04c llvm::Expected<swift::IRGenSourceFileRequest::OutputType> 
swift::Evaluator::getResultUncached<swift::IRGenSourceFileRequest>(swift::IRGenSourceFileRequest 
const&) + 940
12 swift 0x000000010577829d swift::performIRGeneration(swift::IRGenOptions const&, 
swift::SourceFile&, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule> 
>, llvm::StringRef, swift::PrimarySpecificPaths const&, llvm::StringRef, llvm::GlobalVariable*, 
llvm::StringSet<llvm::MallocAllocator>) + 269
13 swift 0x00000001053c21ba performCompileStepsPostSILGen(swift::CompilerInstance&, 
swift::CompilerInvocation const&, std::__1::unique_ptr<swift::SILModule, 
std::__1::default_delete<swift::SILModule> >, llvm::PointerUnion<swift::ModuleDecl, 
swift::SourceFile*>, swift::PrimarySpecificPaths const&, int&, swift::FrontendObserver) + 3002
14 swift 0x00000001053b1d97 swift::performFrontend(llvm::ArrayRef<char const*>, char const, void, 
swift::FrontendObserver*) + 20695
15 swift 0x0000000105332c27 main + 1255
16 libdyld.dylib 0x00007fff70d12cc9 start + 1
17 libdyld.dylib 0x00000000000001ac start + 18446603338623407332

error: Segmentation fault: 11 (in target 'ProjectName' from project 'ProjectName')

Errors

这些是我们正在使用的pods:

pod 'p2.OAuth2', '~> 3.0.0'
pod 'SwiftyJSON', '~> 3.0.0'
pod 'CryptoSwift', '0.8.3'

我们如何解决这个问题?任何帮助表示赞赏。

谢谢。

最近,我也完成了从 Xcode 11.7 到 12.4 的升级,并且在我的项目中的这么多 Swift 文件上遇到了相同的 Segmentation fault: 11 错误,奇怪的是,大多数时候,这些错误没有适当的描述或推理。

我为此花了大约一周的时间,找到了适合我的解决方案。

有一个 BUILD 设置称为 SWIFT_COMPILATION_MODE,只需将此 属性 设置为 Whole Module 并构建您的项目。现在 XCode 将开始用一些可以理解的描述给你错误。您可以继续修复这些错误。

解决这些错误后,您可以将此 属性 设置回其先前的值,即 Incremental

NOTE: It still won't give you the error line number but it will give you the class & method name where this error lies, also the error count will get reduced to the actual count. You can comment all the lines in that function and try to uncomment one (or more) at a time and build your project to find out the problematic line.

这就是我解决这些错误的方法,希望这能帮助您解决问题。