The comment thread on your question suggested that the termination is due to excessive background CPU usage.
Based on your last comment, it sounds like you don't know where to start with Instruments (I've been there) as another commenter recommended, so I'll give some basic info on how to get started with CPU profiling in instruments, and then you can seek out more detailed tutorials online (this WWDC video from Apple is as good a place to start as any: https://developer.apple.com/videos/play/wwdc2019/411/#:~:text=Instruments%20is%20a%20powerful%20performance,optimize%20their%20behavior%20and%20performance )
The following assumes using Xcode 12.1 and its corresponding Instruments version 12.1, but most recent versions should be fairly similar (maybe a button is slightly differently placed, etc. in older versions):
- Open your app project in Xcode, and run it on a real device (simulators will give you information about your mac's CPU usage and will be very different to a real device).
- Go to the Debug navigator in the left sidebar (Cmd+7), select CPU in the sidebar, then click the
Profile in Instruments
button on the top right.
- Select 'Profile Current Session' if asked.
- Instruments should launch and start recording automatically.
- Reproduce the issue on your device.
Now to understand what's being shown in Instruments:
- The top pane (the moving chart) shows your CPU usage over time.
- The bottom pane shows the call tree of processes that have run.
There's a lot of info there, so you want to look at the Filter and configuration bar
at the very bottom of the window, and select all the options in the Call Tree menu in the first instance. It looks like this: 
Here's a short explanation of each of those options:
- Separate by Thread: Shows the processes by thread to help diagnose overworked threads
- Invert Call Tree: Reverses the stack to show the bottom portion first which is likely more useful for troubleshooting
- Hide System Libraries: Removes system library processes so there's less noise & you can focus only on your app's code
- Flatten Recursion: Combines recursive calls into one single entry
- Top Functions: Combines the time the called function used, plus the time spent by functions called from that function. This can help you find your most expensive methods in terms of CPU usage.
Now you've got a filtered list of expensive CPU methods for your app only, and selecting a row gives you more information in the Extended Details pane to the right of the call tree view. This can show you exactly which method in which file of your code was running and even take you to it in Xcode (with a few button clicks).
Hopefully that should be enough to get you started, recognise some potential problem areas in your code that may be the cause of your app being terminated.