Xcode Folders Auto-Expanding When Clicking "Project Navigator"
Input any number of letters in the File filter, then close your Xcode immediately, then reopen your Xcode, then you will see the magic
Demo
I found a solution for this from another posted question.
Delete this file...
MyProjectName.xcodeproj > project.xcworkspace > xcuserdata > myusername.xcuserdatad > UserInterfaceState.xcuserstate
Xcode remember what folders were collapsed / opened
I also had a similar issue with the search filter for an asset catalog failing to clear. Deleting the .xcuserstate file solved that as well
With CocoaPods, delete this:
MyProjectName.xcworkspace > xcuserdata > myusername.xcuserdatad > UserInterfaceState.xcuserstate