Why your iOS apps keep crashing
I remember putting my first application on TestFlight, having high hopes that everything would work perfectly or at-least close to perfect cause everything seemed to work fine from the simulator — I was wrong. I didn’t even get to the splash screen before the app forced closed itself.
This is what I basically check for before uploading any app to iTunesConnect.
- Build configuration
- Un-wrapping optionals
- Error handling
Build Configuration
Frustrated and confused, I thought the problem was probably the iPhone I was using but the result was the same with other models.
I checked through the logs, and there it was — an ‘optimization’ error. By default, we’re always running applications in ‘debug’ mode. Therefore, we’re unable to see the result of what the app would work like in ‘release’ mode.
To enable that, click on Product > Scheme > Edit Scheme > then select ‘release’ from the Build Configuration drop down menu.
Now you’ll run your app as if it were in production mode.
Un-wrapping optionals
Another major problem is how I was unwrapping a lot while coding in Swift.
Most times the data that I’m unwrapping for comes from a server and if something happened such as a network error or a change in the database, the value would be nil and the app would quit from that point.
This is where ‘if let’ or ‘guard statements’ are useful. If the value is nil, it would return either nothing or an alternative you provide.
Error handling
One last thing I observe a lot before creating a prototype is for incomplete features that will in one way or another make the app misbehave. I usually set iOS alerts to tell my Beta users that the feature is still in-development.
That’s it! My quick list of 3 factors to check for 😄 Thanks for reading!