15

I created a branch and made a bunch of changes. I committed the changes and then archived the changes. Then I switched to the master branch and tried to do a merge. It said I had uncommitted changes. So I did a commit on the master branch to see what it was talking about. It said that there is a file called UserInterfaceState.xcuserstate that was modified. So I committed the change (not sure what the change was). Then I tried to merge again. It then opens up a merge window and indicates that there is a conflict with UserInterfaceState.xcuserstate. So I went back to the branch and found that that same file is now needing to be committed. This did not show up before. So I committed it and went back to the master branch. Again I tried to merge but cant because of uncommitted changes. Sure enough, UserInterfaceState.xcuserstate is once again needing to be committed. I committed it and tried to merge. Same problem with conflict. Its a vicious circle.

What is this file and how do I resolve the reported conflict. It does not show up in my project navigation window. Furthermore, it is not in the unix file system. I am totally stuck. Suggestions? I am using xcode 4.5.2

JeffB6688
  • 3,782
  • 5
  • 38
  • 58

4 Answers4

18

just remove files using

git rm --cached *xcuserstate

then do a local commit selecting .DS_Store with miscellaneous message

discard all other changes

pull

push

done :)

Ankit Sachan
  • 7,690
  • 16
  • 63
  • 98
  • 1
    Please could you be more precise as I am not familiar with the underlying xCode project directory structure. e.g. My App is called Twoater. - So where would I go to type in the first command you mention above ? - how do I do a local commit selecting .DS_Store - how do I discard all other changes - etc. – Guy Jun 23 '15 at 06:10
  • So I worked out how to do the first line and resulted in this : Guys-Air:guy.xcuserdatad guy$ git rm --cached *xcuserstate Twoater.xcodeproj/project.xcworkspace/xcuserdata/guy.xcuserdatad/UserInterfaceState.xcuserstate: needs merge rm 'Twoater.xcodeproj/project.xcworkspace/xcuserdata/guy.xcuserdatad/UserInterfaceState.xcuserstate' – Guy Jun 23 '15 at 06:44
  • Then I tried to do a local commit : Guys-Air:guy.xcuserdatad guy$ git commit -m '.DS_Store banished!' U Twoater.xcodeproj/xcuserdata/guy.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist error: 'commit' is not possible because you have unmerged files. hint: Fix them up in the work tree, hint: and then use 'git add/rm ' as hint: appropriate to mark resolution and make a commit, hint: or use 'git commit -a'. fatal: Exiting because of an unresolved conflict. – Guy Jun 23 '15 at 06:58
  • @Harry please use Sourcetree and ignore fikes like ds store, breakpoints_v2 etc – Ankit Sachan Sep 15 '18 at 06:28
5

UserInterfaceState.xcuserstate is where Xcode saves your GUI states, such as window positions, open tabs, expanded nodes in the project inspector etc.

Simply resizing the Xcode window will cause this file to change and be flagged as modified by your source control system. You can make your SCM system ignore specific files that are not important to the project itself.

Git: Git ignore file for Xcode projects
Subversion: SVN ignore pattern with Xcode 4

Community
  • 1
  • 1
DrummerB
  • 39,814
  • 12
  • 105
  • 142
  • Where are these files that your links refer to: .gitignore and .subversion. They are not in ~ and the links suggest. Also, since these links are referring to git, does xcode use git for its SCM? – JeffB6688 Dec 14 '12 at 01:14
  • It supports both, that's why I posted both links. I don't know what you're using. But if you don't know either, you're probably using git, as that's what Xcode uses by default. The ignore files are in your home folder (~). If they don't exist, you have to create them. Note, that these are hidden folders (starting with `.`), so you don't see them in Finder normally. Try `ls -a` on the Terminal. – DrummerB Dec 14 '12 at 01:24
  • 2
    Unfortunately, it still does not work. I create a .gitignore file in my home directory as per the above link. But every time I try to switch branches or merge, it consistently wants me to commit the changes for the UserInterfaceState.xcuserstate file before I merge or switch branches. In other words, the .gitignore is not ignoring that file. I've also tried to restart xcode. That did not help. Any ideas what I might be missing? – JeffB6688 Dec 14 '12 at 04:41
  • If you already committed that file, try removing it (`git rm`). As always with destructive operations, be careful and create a backup if you're unsure what you're doing. – DrummerB Dec 14 '12 at 13:52
  • Based on suggestions in the above link, I already tried to do that also. I've tried both "git rm" and "git rm --cached" on UserInterfaceState.xcuserstate. In either case, I get one of the following errors: "fatal: pathspec 'UserInterfaceState.xcuserstate' did not match any files" or "fatal: pathspec '.xcodeproj/UserInterfaceState.xcuserstate' did not match any files". The actual error depends on where in the directory structure I enter the command. Where should I execute the command? – JeffB6688 Dec 14 '12 at 15:03
  • After considerable experimentation, I was able to remove the file with "git rm -rf project.xcworkspace/xcuserdata". So while I was on the branch I was working on, it almost immediately came back as a file that needed to be committed. Can you think of a reason why the .gitignore doesn't seem to be preventing this file from being considered by xcode? I created the file in my home directory. – JeffB6688 Dec 16 '12 at 16:57
  • What exactly did you add to your gitignore? Try `*.pbxuser`. This should ignore all user specific data. – DrummerB Dec 16 '12 at 17:02
  • basically, I used the one that was suggested on the first answer of the git ignore link. It includes *.pbxuser *.mode1v3 *.mode2v3 *.perspectivev3 !default.pbxuser !default.mode1v3 !default.mode2v3 !default.perspectivev3xcuserdata *.xcuserstate project.xcworkspace/ !xcshareddata !xcschemes *.moved-aside – JeffB6688 Dec 16 '12 at 23:50
  • Thanks for your help. While I observed that this file kept coming back as needing to be committed (i.e. the .gitignore solution did not seem to work), I think I will accept your answer since you did if fact answer the question as I posed it and it led me to the final solution. I am back to a working master branch. I am coming to the conclusion that using branches in xcode can result in very bad things happening (at least I have not had much luck the last 2 times I used it for a significant change to the master branch). – JeffB6688 Dec 17 '12 at 23:47
  • I recommend using git on the command line, instead of the Xcode menus. You'll get a better understanding of how it works. Xcode just offers a few menus and buttons for the most common git commands (status, commit, checkout). You might also want to try [SourceTree](http://www.sourcetreeapp.com/). – DrummerB Dec 18 '12 at 11:41
0

I tried all the commands does not help me. So i thought to delete in directory.

Right Click on xcode Project File -> Show Package Contents -> project.xcworkspace -> Right Click on xcworkspace File -> Show Package Contents -> xcuserdata -> mac"mac is an system name".xcuserdatad -> UserInterfaceState.xcuserstate -> Delete your headache here i mean UserInterfaceState.xcuserstate file.

then commit using commands and do as usual procedure.

karthikeyan
  • 3,821
  • 3
  • 22
  • 45
0

Simple Run below CMD-

git rm --cached [HERE ENTER YOUR UserInterfaceState.xcuserstate PATH YOU CAN COPY AND PASTE PATH FROM TERMINAL WARNING]

like in my case:

git rm --cached CabAppUser.xcworkspace/xcuserdata/shinewebsolutions.xcuserdatad/UserInterfaceState.xcuserstate

Thanks

Rohit Nishad
  • 428
  • 4
  • 7