Abort Trap: 6 error after upgrading to Xcode 14

I just updated my Xcode to Version 14.1 (14B47b) from version 13.4. When I try to run my SwiftUI project in the live preview, the "Abort Trap" errors showed everywhere in the project.

Part of the error log is as below:

CompileSwift normal x86_64 /Users/apple/Downloads/SwapSpot/SwapU/ViewModels/ItemVMs/ItemGridViewModel.swift (in target 'SwapU' from project 'SwapU')

unknown:0: error: fatal error encountered during compilation; please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the project

unknown:0: note: SmallVector unable to grow. Requested capacity (4294967297) is larger than maximum value for size type (4294967295)

Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the project and the crash backtrace.

I found some posts that answer as such:

We will not observe "Abort: trap 6", if under Build Settings, we are using "Optimize for Speed" in Debug, instead of "No Optimization"

We can also avoid "Abort: trap 6", if we change the following code

guard let batchUpdateResult = batchUpdateResult else { return }

to

guard let batchUpdateResult2 = batchUpdateResult else { return }

I tried both methods. Renaming the guard let variable did not work at all. Changing the optimization level in the target removed all the Abort Trap errors, and the project runs successfully in the simulator.

However, the live preview stopped working due to the optimization level. The new error is stated as below:

OptimizationLevelError: not building -Onone

"SwapU.app" needs -Onone Swift optimization level to use previews

I believe this is a compiler error. Can anyone help me avoid this while keep the live preview working?