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

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/*

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