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

53,611

Solution 1

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

Solution 2

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

Solution 3

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

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

https://www.programmersought.com/article/1594916500/

Solution 4

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

Solution 5

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

Share:
53,611
Fernando
Author by

Fernando

Updated on July 09, 2022

Comments

  • Fernando
    Fernando almost 2 years

    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: MyProject.xcodeproj/project.xcworkspace/xcuserdata/fernando.xcuserdatad/UserInterfaceState.xcuserstate
    

    Does anybody have any idea what's wrong?

  • Leonard
    Leonard about 5 years
    *xcworkspace/xcuserdata/* worked for me! thank you!
  • NFerocious
    NFerocious about 5 years
    sure. you should also remove that from cache if you previously commit that file
  • alekop
    alekop over 2 years
    None of these work for me. But just xcuserdata, with nothing else does ignore it.