Velvet Star Monitor

Standout celebrity highlights with iconic style.

news

.gitignore for everything inside the xcuserdata folder does not ignore an xcuserstate file

Writer Andrew Mclaughlin

I'm working in a Xcode project, and I'm trying to configure the .gitignore to not get anything inside the xcuserdata folder.

I have the following .gitignore:

# Xcode
.DS_Store
*/build/*
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata
profile
*.moved-aside
DerivedData
.idea/
*.hmap
xcuserdata/*

but every time that I build/run the project and execute git status, it still shows the following midified file:

modified: 

Does anybody have any idea what's wrong?

1

10 Answers

I found the solution

the problem was not in the .gitignore file

the problem was the UserInterfaceState.xcuserstate that was not removed from git server, found the solution in the following link:

Can't ignore UserInterfaceState.xcuserstate

Additional info

I have also encountered this and seems not to work since .gitignore still adding them after committing. What I have added does the charm for me

.... this can't be read by the .gitignore:

xcuserdata/*

adding this works for me:

*xcworkspace/xcuserdata/*

or to be read:

*/xcuserdata/*
3

On top of adding *.xcuserstate to your .gitignore file, remember to remove your cached *.xcuserstate

git rm --cached [YourProjectName].xcodeproj/ YourUsername].xcuserdatad/UserInterfaceState.xcuserstate

If you used git, you can add .gitignore

# Xcode
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
*.moved-aside
DerivedData
.idea/
*.xccheckout
*.moved-aside
xcuserdata/
*.hmap
*.ipa
*.xcworkspace
*.xcuserstate // <--- Here
!default.xcworkspace

I don't see any logic here. However, in my case only movingxcuserdata/to the most down of the .gitignore file helped.

Nothing worked but this for me, as I wanted to commit Pods that also have .xcuserdata in it:

**/xcuserdata/*

For me nothing worked, but this

add this line to your gitignore

*.xcuserdata

Coming late to this question but this site helped me out with this problem:

Specifically using the labes swift and xcode to generate the following:

FWIW, my xcuserdata folder was NOT being tracked by git yet and was still showing up in git status. The problem was that I had a space before xcuserdata in my .gitignore file.

You could simply do

 git checkout -- <file>..." to discard changes in working directory

Example:

 modified: git checkout -- 

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy