Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Source Control - Discard all changes deleted my xcworkspace and I can't fix it

I was trying to undo changes on my project to the last committed Source Control state, however when I pressed 'Discard all changes' weird behaviour happened.

The first time some of the files reverted whilst others didn't. So I pressed the button again and a blurb popped up saying something about needed to re-save the 'xcworkspace'. I pressed okay and half my files disappeared from the xcode file list on the left, really random files that hadn't been edited at all. So I decided to press revert again to see if I could get back to my original state, and now all my files have disappeared from the xcworkspace. So my screen now looks like this:

enter image description here

I have tried restoring the files from my trash (as this is where random ones have appeared) but the workspace is never restored. I use MapBox so I have 2 projects building in to 1 workspace, but the podfile will now not install.

Can anyone give me advice on how to get this back to it's original state as I have been trying for a few hours but can't find any information.

like image 973
Elliott D'Alvarez Avatar asked Oct 07 '13 13:10

Elliott D'Alvarez


Video Answer


1 Answers

I felt horrible when I did this. I really thought I had to rebuild everything over again. Luckily, it was easy to repair.

Xcode removed all the "non-essential" files. This includes your Podfile (and if applicable, GoogleService-Info.plist).

To Repair:

  1. Go to Terminal and create a Podfile in your project folder $ pod init

  2. Update your Podfile with the pods you need

  3. Run $ pod install

(4.) To re-generate the GoogleService-Info.plist file, go to your console.firebase.google.com > Settings > Project Settings > Download the latest config file for the appropriate project iOS app and save to your local project folder. Your workspace should recognize the file in the Project Navigator list.

Once you open your workspace, select new Scheme and everything should be back to normal.

To avoid future regressions:

Go to Terminal

git add -A

to add the pod files, then

git commit -m "Save pod files"

to save pod files. I believe git from Xcode ignores the pod and scheme files.

like image 157
grehce Avatar answered Oct 13 '22 21:10

grehce