Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

phjo

macrumors regular
Original poster
Jan 8, 2008
149
1
Hi,

I decided that my next projects would benefit for some versioning (which I never really used so far), and decided to leave the <<Create local git repository>> checked with a new project.

I soon made a mistake though, while adding a necessary framework to my project (Accelerate, but it doesn't matter much) when I left xcode copy the framework files to the project, so I deleted it and added it again, making sure this time the framework files would not get copied...

Alas, the first git commit failed with a fatal error, such as 'Could not switch to .../myProject/Accelerate.framework/Headers...

I know the git commits could be made from terminal, and I found some commands to delete the links to the removed files, but as soon as I try to commit again from within Xcode, the same error comes back, and the only way to make it work is to copy the missing files (or at least the folders I guess) back into the project, which feels a bit stupid, and certainly ugly...

So, the question is : what could be the proper way to clean my mistake and have git and xcode running well together ?

phjo
 

jared_kipe

macrumors 68030
Dec 8, 2003
2,967
1
Seattle
It is pretty hard for me to tell exactly what is going on from this description. 'Could not switch to ...' sounds like it is trying to branch/checkout.

Did you stage the files then remove them from the folder? If thats the case, just remove them from the stage.

Look in the physical folder and see if you deleted the files you think you did.

Navigate to the folder in terminal and type 'git status', post what comes back.
 

SplitIt!

macrumors newbie
Jul 10, 2012
23
0
Git certainly has a learning curve.

I use git both from the command-line (managing branch and pushing/pulling from my private GitHub repository) and the Xcode commit interface. The Xcode commit interface in 4.4 is actually really really nice.

It's hard to actually know what happened here.

I guess if I had this problem, I would probably revert to my last commit:

Code:
git reset --hard HEAD
 

phjo

macrumors regular
Original poster
Jan 8, 2008
149
1
Actually, it seems this morning that I fixed it, not sure why though, so I'll try to retrace my steps with a new empty project :

So within XCode 4.4, I created a new project (iPhone utility application, named testForGit...), did the same mistake of adding the Accelerate.framework to the project, copying the files/folders (if needed...). Indeed a copy of the framework (built for iOS devices, unsuitable for the simulator...) is present at the same level than the folder for the project files testForGit and the xCode testForFit.xcodeproj file.

At this point, git status gives :

Code:
# On branch master
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#	new file:   Accelerate.framework/Accelerate
#	new file:   Accelerate.framework/Frameworks/vImage.framework/Headers/Alpha.h
#	new file:   Accelerate.framework/Frameworks/vImage.framework/Headers/BasicImageTypes.h
#	new file:   Accelerate.framework/Frameworks/vImage.framework/Headers/Conversion.h
#	new file:   Accelerate.framework/Frameworks/vImage.framework/Headers/Convolution.h
#	new file:   Accelerate.framework/Frameworks/vImage.framework/Headers/Geometry.h
#	new file:   Accelerate.framework/Frameworks/vImage.framework/Headers/Histogram.h
#	new file:   Accelerate.framework/Frameworks/vImage.framework/Headers/Morphology.h
#	new file:   Accelerate.framework/Frameworks/vImage.framework/Headers/Transform.h
#	new file:   Accelerate.framework/Frameworks/vImage.framework/Headers/vImage.h
#	new file:   Accelerate.framework/Frameworks/vImage.framework/Headers/vImage_Types.h
#	new file:   Accelerate.framework/Frameworks/vImage.framework/vImage
#	new file:   Accelerate.framework/Frameworks/vecLib.framework/Headers/cblas.h
#	new file:   Accelerate.framework/Frameworks/vecLib.framework/Headers/clapack.h
#	new file:   Accelerate.framework/Frameworks/vecLib.framework/Headers/vBasicOps.h
#	new file:   Accelerate.framework/Frameworks/vecLib.framework/Headers/vBigNum.h
#	new file:   Accelerate.framework/Frameworks/vecLib.framework/Headers/vDSP.h
#	new file:   Accelerate.framework/Frameworks/vecLib.framework/Headers/vDSP_translate.h
#	new file:   Accelerate.framework/Frameworks/vecLib.framework/Headers/vForce.h
#	new file:   Accelerate.framework/Frameworks/vecLib.framework/Headers/vecLib.h
#	new file:   Accelerate.framework/Frameworks/vecLib.framework/Headers/vecLibTypes.h
#	new file:   Accelerate.framework/Frameworks/vecLib.framework/Headers/vectorOps.h
#	new file:   Accelerate.framework/Frameworks/vecLib.framework/Headers/vfp.h
#	new file:   Accelerate.framework/Frameworks/vecLib.framework/libBLAS.dylib
#	new file:   Accelerate.framework/Frameworks/vecLib.framework/libLAPACK.dylib
#	new file:   Accelerate.framework/Frameworks/vecLib.framework/libvDSP.dylib
#	new file:   Accelerate.framework/Frameworks/vecLib.framework/libvMisc.dylib
#	new file:   Accelerate.framework/Frameworks/vecLib.framework/vecLib
#	new file:   Accelerate.framework/Headers/Accelerate.h
#
# Changes not staged for commit:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#	modified:   testForGit.xcodeproj/project.pbxproj
#
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#	testForGit.xcodeproj/project.xcworkspace/
#	testForGit.xcodeproj/xcuserdata/

Now I delete the Accelerate.framework folder I copied by mistake, from within xCode, choosing to moving it to trash.

At this point, git status gives this :
Code:
# On branch master
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#	new file:   Accelerate.framework/Accelerate
  A lot of deleted lines here...
#	new file:   Accelerate.framework/Frameworks/vecLib.framework/vecLib
#	new file:   Accelerate.framework/Headers/Accelerate.h
#
# Changes not staged for commit:
#   (use "git add/rm <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#	deleted:    Accelerate.framework/Accelerate
#	deleted:    Accelerate.framework/Frameworks/vImage.framework/Headers/Alpha.h
#	deleted:    Accelerate.framework/Frameworks/vImage.framework/Headers/BasicImageTypes.h
  the same there
#	deleted:    Accelerate.framework/Frameworks/vecLib.framework/libvMisc.dylib
#	deleted:    Accelerate.framework/Frameworks/vecLib.framework/vecLib
#	deleted:    Accelerate.framework/Headers/Accelerate.h
#	modified:   testForGit.xcodeproj/project.pbxproj
#
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#	testForGit.xcodeproj/project.xcworkspace/
#	testForGit.xcodeproj/xcuserdata/

Then I add the reference only to the framework, making sure this time the framework itself is not copied to the project. At this point, git status shows the same output than the previous one.

Now if I try to commit from within xCode, the left side shows three files changed, but the commit button on the bottom right shows that 30 files will get commited, which is not really a surprise given the git status.

As for the error message, it was this time : Could not switch to '/Users/phjo/xcode/iPhone/testForGit/Accelerate.framework/Frameworks/vImage.framework/Headers': No such file or directory

Indeed not, is it now in the garbage can...

What I don't understand this morning is that it seems a git commit -a seems to fix the problem, and subsequent commits from withing xcode work, while everything I tried yesterday failed...

Anyway, problem solved. Do you think a bug report should be filled about xcode behaviour quoted there, or do you think it normal ?

Thanks,

phjo
 

jared_kipe

macrumors 68030
Dec 8, 2003
2,967
1
Seattle
Ok, so what it is saying is that you staged all those files. Then deleted the file, but didn't restage it (aka removing the original from the stage).

"git commit -a" fixes it because it stages all changes i.e. stages the deletes.

I suggest downloading SourceTree for free. Though I'm not super familiar with the Xcode interface, SourceTree is 'probably' a more transparent GUI for git.
 

phjo

macrumors regular
Original poster
Jan 8, 2008
149
1
Hi,

Actually, it is not exactly what I wrote, or did... I did not stage those added files, Xcode did it for me. What Xcode didn't do though is to stage their deletion, although I deleted the added framework and files under xcode supervision. It sounds like a bug to me, and I'll probably file a bug about it, but first I'm reading some git documentation.

Thanks for the hint about SourceTree. I had already downloaded and installed it, but did not play much with it yet. Although I'd rather have an integrated development environment, I'll have a look at it, and at bitbucket services. (Quite surprised they offer private repositories for free...)

phjo
 

jared_kipe

macrumors 68030
Dec 8, 2003
2,967
1
Seattle
I didn't mean to sound like 'you' explicitly staged the files, I was just explaining what the 'git status' meant. It is pretty hard to tell what actually happened.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.