简体   繁体   中英

Xcode keeps expanding all groups in the project navigator

Since a couple days ago Xcode keeps expanding all the groups and subgroups in the project navigator.

I have repeatedly collapsed them so I can focus on what I'm working on and then I go back and they're all expanded again.

Has anyone else experienced this?

I collapse a group, move to a different tab in Xcode and then back and the groups are all expanded again.

It's really frustrating as I keep losing track of the files I'm working with.

OK, I had had enough of this now and decided to try several things out.

Xcode had got to the stage where the project navigator was just broken. I couldn't collapse (permanently) and groups and I couldn't move files around or anything.

In the end what fixed it was deleting the .xcuserstate file and restarting Xcode.

I lost my tabs and everything but setting them back up took a couple seconds and everything is working fine now.

I also was experiencing this annoying scenario in Xcode 9.2 where the project groups kept expanding themselves.

To fix it:

First, close your project in Xcode. (Otherwise, Xcode will replenish this file upon closing the project.)

Then delete the following file (or move the file somewhere else): [MyProject].xcodeproj/project.xcworkspace/xcuserdata/[MyUser].xcuserdatad/UserInterfaceState.xcuserstate

Remember to use the "Show Package Contents" option in Finder.

扩展/折叠所有Xcode的组文件夹的一个很好的快捷方式是cmd +单击任何组箭头

I wrote a shell script that gets rid of all these garbage files that sometimes make problems in xcode:

printf '\33c\e[3J'

RED=`tput setaf 1`
BLUE=`tput setaf 4`
NOCOLOR=`tput sgr0`

BASEDIR=$(dirname "$0")
path1="prj.xcodeproj/xcuserdata"
path2="prj.xcworkspace/xcuserdata"

echo "${BLUE}[XCode cache files pruner, created by Deya Eldeen Elkhawaldeh]${NOCOLOR}"
echo "REMOVING ${NOCOLOR} $BASEDIR/${RED}$path1${NOCOLOR}"
rm -R "$BASEDIR/$path1/"
echo "REMOVING ${NOCOLOR} $BASEDIR/${RED}$path2${NOCOLOR}"
rm -R "$BASEDIR/$path2/"

echo "${BLUE}Done,${NOCOLOR}"

it's hosted in github, maybe someday I will update it with more features, https://github.com/deya-eldeen/XCodeProjectCleaner

In my case, I accidentally selected "Show only files with source control status" option in "project navigator". Check if you also selected this. Unselecting this option resolved my issue. Noticed this after searching for many answers on SO.

I had a similar issue in a workspace with an SPM and an iOS project. The groups' state would be reset to an older expansion state whenever I switched navigators. What worked for me was to perform a minor group change that caused the project to enter a staging state in version control. I then discarded the change in the project and that reset the entire group expansion state. The problem disappeared ever since.

For me, it was that I had accidentally typed into the project-navigator text filter at the bottom (random keystroke), with a common letter that caused all folders to expand.

Deleting the user data didn't seem to reset that, I just had to finally notice it and clear the search filter.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM