问题
I am in the process of updating a project to iOS 11/Swift 4. I have updated to Swift 3.2 and have a project that builds with one warning: "Conversion to Swift 4 available". So I click the warning and start the migration assistant with the option "Minimize Inference" when asked about Swift 4 @objc Inference.
The build fails quite quickly with this message: Command failed due to signal: Segmentation fault: 11
Stack trace:
0 swift 0x000000010afabdba PrintStackTraceSignalHandler(void*) + 42
1 swift 0x000000010afab1f6 SignalHandler(int) + 662
2 libsystem_platform.dylib 0x00007fff9ec2bb3a _sigtramp + 26
3 swift 0x000000010a10155a clang::ASTReader::readTypeRecord(unsigned int) + 18634
4 swift 0x00000001085e4ff0 swift::migrator::updateCodeAndEmitRemap(swift::CompilerInstance*, swift::CompilerInvocation const&) + 960
5 swift 0x000000010791b775 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 1925
6 swift 0x0000000107919784 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 7716
7 swift 0x00000001078ce6a8 main + 12248
8 libdyld.dylib 0x00007fff9ea1c235 start + 1
Did anyone else have a similar issue and found a solution for it?
UPDATE: I also tried Swift 4 @objc Inference "Match Swift 3 Behavior" with the same results.
回答1:
It appears to be a Swift bug which has been filed here: https://bugs.swift.org/plugins/servlet/mobile#issue/SR-4646
That said, have you tried cleaning and deleting derived data?
回答2:
The only thing that helped me (as other than the segmentation fault code 11, there wasn't ANY information what was causing the error), was to disable Whole Module optimization (set Compilation Mode to Single File under Target -> Build Settings) for all configurations. The setting will be re-enabled for Release configs after you go through the conversion or you can re-enable it yourself.
来源:https://stackoverflow.com/questions/46325113/segmentation-fault-when-converting-to-swift-4