ARTICLE AD BOX
I have some flows in my iOS app which require us to open an SFSafariViewController. One such example is a login flow which opens the SFSafariViewController for SSO purposes.
We have a UITest which goes through this flow, opens the SFSafariViewController, we look for the close button and then subsequently tap it to dismiss the SFSafariViewController. This test passes locally but has been extremely flaky on CI especially since we opted to use iOS 26 devices.
When I look at the videos in the XCTestResult, one thing I notice is that it takes extremely long for the SFSafariViewController to render and load.
I was wondering if there was any way to replace or mock this with a custom view ?
Two ideas that come to mind:
Swizzle a custom view to replace what loads as the view in the SFSafariViewController - I have no idea how to do this but just reading up, was wondering if this is even a realistic solution and is it robust going forward on CI ?
The other thing that comes to mind is creating some sort of a protocol, e.g WebViewProvider for example and the prod app implements it making use of an SFSafariViewController but the UITest uses a mock which is a normal view controller which can load faster. My only concern with this is that with SSO and similar things, how do we ensure call backs from this mock view which are provided by SFSafariViewController
I hope to not bias you with the ideas mentioned, I just wanted to show that I've done some thinking before posting. My bigger question is more around if anyone faced similar problems and found a reliable replacement to using SFSafariViewController in your UITests that were reliable on CI as well?
