bodacious
bodacious

Reputation: 6695

Source control in XCode is a nightmare - can anyone offer advice?

Using Git with Xcode (4.3) is a real nightmare.

Here's a scenario...

I want to add a new feature, so I create a new topic branch.

I add my new feature and I'm ready to commit, rebase and merge...

I commit my changes - fine.

I jump back to master to pull changes (in case someone else has updated the code). Suddenly I get:

error: Your local changes to the following files would be overwritten by checkout:
myProject/project.xcworkspace/xcuserdata/Bodacious.xcuserdatad/UserInterfaceState.xcuserstate

huh? I just committed.

Xcode likes to change my project.xcworkspace files every other second which makes it almost impossible to make clean, atomic commits.

What's more, if I do commit the changes in project.xcworkspace and quickly jump back to another branch (in order to merge into Master for example) then Xcode will complain that the files have changed and probably crash too.

From what I gather, I can't add these files to my .gitignore either.

Do I have to accept that a concise and orderly git strategy is not possible with Xcode, close Xcode before doing any Git management, or is there another option available?

Upvotes: 10

Views: 6022

Answers (4)

ThomasW
ThomasW

Reputation: 17307

I just add those files to my .gitignore file. There is no need to share them with other developers.

So I have:

*.xcworkspace

In .gitignore

Note that the stackoverflow question you linked to says to not exclude project.pbxproj, but it doesn't say not to exclude *.xcworkspace.

However, I'm not using the workspace feature at this time. If you do use the workspace feature you may want to include those files, but ignore the xcuserdata files.

Upvotes: 12

Nick Yap
Nick Yap

Reputation: 887

Here's what worked for me on Xcode 5.1:

  1. Commit and push your changes for the branch you're on.
  2. Go to Xcode > Source Control > Discard all changes (should only discard the workspace problem)
  3. Checkout the branch that you want and merge or whatever you're trying to do.

Note: if you wait too long or do anything in Xcode before checking out the new branch, you might have to discard changes again

Upvotes: 0

Eric
Eric

Reputation: 16921

If you can't push your commit just because UserInterfaceState.xcuserstate has been modified, here's a quick fix:

  1. Open the Organizer, go to Repositories, copy your the commit's code (something like f01a2147218d by username)
  2. Open the terminal, go to your project's folder, do git reset --hard f01a2147218d
  3. Push the commit!

Upvotes: 0

Amber
Amber

Reputation: 526473

The question you linked was only referring to the xcodeproject/project.pbxproj file. You should be able to safely .gitignore the other files.

Upvotes: 2

Related Questions