iPad: Fix split view not working after the initial launch #2 #15989
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.

WOOMOB-1009
Description
When the Woo app is initially launched and user logs in, Orders and Products tab are not displayed in a split view. The app needs to be killed and relaunched for a split view to appeared.
The iPadOS 18 + Xcode 16 hack was not working properly on first launch after login because it requires view.window to be available to access the window's trait collection. It turns all the views into
.compact, not just the tab bar itself.During initial login flow:
Wrong solution
Calling
fixTabBarTraitCollectionOnIpadForiOS18onviewDidAppearwas a bad choice (implemented in #15985 and reverted in #15988). The fix worked with the first login, but would make tabs appear correctly after a delay during the subsequent launch, also sometimes causing crashes when opening Order and Product tabs.Better solution
There are two issues that need to be fixed with the original
fixTabBarTraitCollectionOnIpadForiOS18solution:windowis not yet accessible to get an overalltraitCollectioncollection if the viewController is not added in the view hierarchyTo solve those issues we can do two things:
windowis not yet accessible on a view but can be accessed throughAppDelegate.shared.window, since the window it self is loaded.fixTabBarTraitCollectionOnIpadForiOS18after tabs are loaded (fixTabBarTraitCollectionOnIpadForiOS18)Steps to reproduce
First Launch
Subsequent Launches
Testing information
On iPad Air 18.5 simulator and iPad Air M2 26. device:
RELEASE-NOTES.txtif necessary.