Reputation: 2811
I just need to revert my project back to a previous Commit. I'm already doing Version Control using XCode's built-in tool (and git).
I have already seen this too : [How to switch entire XCode project to previous commit] but I have nothing to do with SourceTree or Schemes.
I have already tried to revert using SmatGit but XCode said it couldnt understand the resulting project's format.
I have tried many commands from here How to revert Git repository to a previous commit? and here How do I restore from a previous commit on Xcode 8?
I was working on the Tinder Clone from the Udemy Course, when i added the Facebook SDK, parse stopped letting my USer login. Now i want to delete all the additions for adding the FB SDK, but the methods I have tried provided have failed to help so far. Still working, but I hope someone can help.
Upvotes: 0
Views: 595
Reputation: 2811
this is the best try i have seen so far...
#!/bin/sh
#
# restores an old version of xcodeproject from git repository
# into folder $HOME/gitcopy
# current directory must be the rootdir of the project
# Xcode should not access the same project at this time
#
set -x
PROJECT_ROOT=.
COPY_DEST=$HOME/gitcopy
if [ -e *.xcodeproj ]
then
git log
echo "Which version ?"
read x
git checkout $x
git checkout -b copyVersion
cp -R $PROJECT_ROOT $COPY_DEST
git stash
git checkout master;
else
echo "No xcode project root folder";
fi
it's from How to restore previous version of code in Xcode, but more files are getting lost in the process than necessary...
Ok.. that was the Ultimate Solution. The problem had been that XCode had created some files i had added only by reference, and were not added to the Project, so, i think git didn't know about them.
When i finally added the Missing (highlited in red) files manually from the project's old copy, everything stated working according to the commit of interest.
Thanks for the help.
You have to run the script, select the code for the commit you want, then the solution will be copied into ~/gitcopy directory. Open the Project in XCode and copy any missing files from a previous copy (or, make references) of the Project...
Upvotes: 0
Reputation: 387
I never trust Xcode for these kind of operations. Would do
run either of these commands from command prompt
a) git stash
b) git reset --hard
If you do the first, you can apply your changes again by git stash apply
Upvotes: 2
Reputation: 518
"Compare File Versions to Revert Lines of Code Choose View > Version Editor > Show Comparison View to compare versions of files saved in a repository. "- Hackless How to restore previous version of code in Xcode
Upvotes: 1