This is normally a Swift compiler bug, and if compiler is already latest-version, we can only workaround it, for example:
Possible workarounds
#1
Go to project Build settings -> Swift Compiler - code generation -> Optimization Level
-> For both Debug & Release select option "Fast,Single-File Optimization[-O]

Above forces compiler to operate a little differently, which seems to prevent crash.
Note that both "-O
" and "-Osize
" may fix the crash, but I prefer -O
to match release's settings, and avoid surprises in release.
#2
Go to "Build settings
", and set "Compilation mode
" to "Whole Module
" instead of "Incremental
".
By default for Debug it's Incremental
, and for Release it's Whole Module
.
#3
Try latest Swift compiler, which is named "toolchain" and is downloadable at:
https://swift.org/download
WARNING: You can not upload such "toolchain" build to App-store .
But at least you should be able to test locally.
For App-store, you need to compile with Swift compiler that comes with your Xcode
(or latest Xcode, if your current Xcode version does not compile).
#4
Last and least (don't do this);
edit entire project's and/or pods' source-codes, and ensure guards have separate name than what they guard.
For example, replace:
guard let myVariableName = myVariableName else { return }
With something like:
guard let myDifferentName = myVariableName else { return }
Of course, now all lines after guard
need to use myDifferentName
.