Trace/BPT trap: 5

Hi there,
I am developing an iOS app and while building my project I run into the following error message:
Error: Trace/BPT trap: 5

I didn't find anything online to fix this problem, so I wanted to know, if anyone here might be able to help.
I also had issues with Cocoapods and my Silicon Mac, so I want to list my steps I've tried fixing:

First my setup:
  • M1 MacBook Pro, macOS 11.1

  • XCode Version 12.4

  • Cocoapods with Pods for Firebase Swift, Auth, Firestore and Storage

Steps I tried fixing:
  • cmd + shift + k for cleaning the build folder

  • closing XCode and opening Terminal using Rosetta

  • delete ~/Library/Developer/Xcode/Derived Data - Folder

  • pod deintegrate in project directory

  • delete Podfile.lock, app.xcworkspace, Pods directory

  • pod install

  • in app and pods projects build settings setting Excluded Architectures for any iOS Simulator SDK to arm64

  • setting Build Active Architecture Only to yes

  • convert Pods Project to Swift 5

  • build Pods Project

  • build app project

And then the attached error down below occurs.
I hope someone can help me fixing this, because I already wasted so much time on that and have a deadline on that app, because it is a project for university..




I read, that the error occured while serializing the class BaseViewModel, so I'll attach my code from Base.swift containing that class as well.







I have the exact same problem. MacBook Air 2020 after I updated XCode to 12.4.
Did you ever find a fix for this problem? I just ran into it when I tried to set a database variable inside a class like you did with "private var db = Firestore.firestore()" in your Base.swift file. I found that's the problem because my app runs when I comment the line out, however I don't know why that's causing a problem.
I fixed it with using Swift Package Manager and unlink the cocoapods integration..
Simply delete the .xcworkspace, the Podfile (plus the Podfile.lock) and the Pods Folder and add Firebase via Swift Package Manager as described here https://github.com/firebase/firebase-ios-sdk/blob/master/SwiftPackageManager.md.

Did anyone manage to solve this one?

I'm facing the same problem now, but I'm in trouble because I can't solve it. If anyone knows a solution, please let me know. I'm using M1mac.

I hit the same error immediately after starting a new project with CoreData, using the default generated code (Xcode 13.3.1) and adding a new View over a new, different Entity. I changed the default PersistenceController preview to reference the new Entity and the the crash disappeared. Two beers all around. However, I don't fully understand the relationship - now the new canvas View reflects the data from the default View and the simulator reflects no data - nuts! Let the elimination process begin, Watson!

Cancel my comment about the canvas - the default code puts the list in a NavigationView and reflected a Date() attribute the I had created in the PersistenceController - so all good.

I had the exact same issue with a SwiftUI application I am working on, and I found what was causing it for me (it may be different for you, but it's worth a check).

By default, a fresh SwiftUI file will contain the actual view code and a preview block to generate that view code in the canvas. On some of my view files, I just deleted the preview block (since it isn't strictly needed, as you can still run your app in the simulator). On one of my views (called "TestView.swift"), I had not deleted the preview block, nor had I modified it so it would work properly.

The problem was that the EnvironmentObject I instantiated in the base parent view (the app entry point) was being passed to each individual view file that required it (which was most of them since this EnvironmentObject happens to be the ViewModel that powers the logic of my app), including TestView, but it wasn't being referenced at all in TestView's preview block. Without any reference to that parent environment object, the app sort of freaks out and throws this error.

To fix it, I could have just deleted the preview block here as well, but instead I created a dummy instance of my ViewModel (that base environment object-- called ContentModel in my app) and passed it into the .environmentObject modifier for the view in the preview block. To illustrate, here is the code with that modifier added:

struct TestView_Previews: PreviewProvider {
  static var previews: some View {
    TestView()
      .environmentObject(ContentModel())
  }
}

Adding this just shows a sort of dummy preview in the canvas, but at least it doesn't crash anymore.

I hope this made sense and it helps you solve your own issue. Maybe you have one of these default preview blocks somewhere that you need to either modify or delete. Good luck!

-Kaleb W. -AppKid LLC

The .environmentObject was the reason I was getting it as well. The following all have to be true for prevent the crash and to compile properly:

  • The model has to be @Observable.
  • You must include @EnvironmentObject var modelData: ModelData in your view definition.
  • You need the .environmentObject(ModelData()) modifier on the view instantiation in the preview.
Trace/BPT trap: 5
 
 
Q