There are a lot of things to like about SwiftUI. Its declarative API makes it possible to build many common types of iOS views with very little code, its powerful state management system ensures that our UIs stay in complete sync with their underlying state and data, and Xcode’s new Previews feature lets us iterate on our views faster than ever before.
However, for all of its advantages, SwiftUI still has a long way to go when it comes to its overall compatibility with other tools. Even many of Apple’s own frameworks have not yet been updated to offer native SwiftUI integrations, and it’s very common to have to do at least some amount of work to make third-party tools and libraries work well in the declarative world of SwiftUI.
Thankfully, Instabug already works incredibly well with SwiftUI-based apps. Both network and UI events are still automatically logged, just like they are when using UIKit, and users and testers can keep invoking the Instabug feedback UI just like before.
That being said, there are a few simple things that we can do to make Instabug even easier to use within the context of SwiftUI, which is exactly what we’ll take a look at in this article.
Starting Instabug when using the new SwiftUI app lifecycle
Now that we’ve finished configuring Instabug within our SwiftUI-based app, let’s also take a look at how we could make it really simple to send Instabug UI events directly from within a SwiftUI view.
View appearance and disappearance events
To make our Instabug timelines even nicer, though, let’s also log a separate appearance event for each of our top-level SwiftUI views. That way, we’ll be able to set custom names for each of our app’s various screens, which will make it much easier to get an overview of how a user navigated through our app before encountering a bug or a crash.
Of course, none of the above steps are really needed in order to make Instabug produce rich bug reports for us, but a little bit of extra metadata can go a long way when investigating bugs and crashes, especially UI-related ones.
But by adding a few tweaks here and there we can make the experience of using Instabug within SwiftUI-based apps even better — so I hope that you found the tips within this article useful, and feel free to reach out via either Twitter or email if you have any questions, comments or feedback.
Thanks for reading!
- Swift 5 Module Stability Workaround for Binary Frameworks
- Creating and Distributing an iOS Binary Framework
- TestFlight Beta Testing: Setting Up Effective Beta Tests
- The Beginner’s Guide for iOS App Beta Testing
Instabug empowers mobile teams to maintain industry-leading apps with mobile-focused, user-centric stability and performance monitoring.