XCode Source Control - Discard Changes Deleted imported files - ios

I am doing a game for iPhone and iPad using SpriteBuilder. SpriteBuilder makes a couple of files in the same folder as the XCode project. I was using Source Control and I just made a commit, then I changed a little bit of the code in the XCode (I changed nothing of the spritebuilder files) and then I changed my mind and I wanted to go back to the commit I made. So I did source control -> discard changes. The XCode successfully replaced the new code with the old code but it erased most of my SpriteBuilder files!!
How do I get my SpriteBuilder files again?
Screenshot of the last commit. You can see that xcode knows when the spritebuilder files are changed so it should keep them no?

Unfortunately the way Xcode calls Git appears to do this. All may not be lost, however. Check the trash for your missing files.

Quit Xcode.
Open the file you wish to bring back your lost changes to using TextEdit.
Go to File -> Revert To -> Browse All Versions...
Scroll through the available versions. Hopefully you will have many available to choose from.
Select a version and hit Restore.
Follow 1-5 for all necessary files.
Launch Xcode. You should now see the M next to these files in Project Navigator indicating they include uncommited changes (the changes you previously discarded).

Related

How to get back to an older version of my project Xcode 10

I have a very old project I was working on to revive it. I deleted some infoplist.strings files first, then by mistake the storyboard file. So Xcode 10 started complaining. I thought maybe I can get my deleted files back if I press Source Control -> Discard all changes. And then I lost the whole project, code and everything. All the files in the project are gone.
So please tell me there is a way to get back my files.
PS: I did close the project that went wrong. And opened it again, then there was thus, the basic files a simple project starts with.
You can go back to the last commit before you discarded the changes by using Xcode's source control navigator. Select the current branch from the source control navigator to see all the commits for that branch.
Select the commit you want to go back to, right-click, and choose Branch from. A sheet opens. Enter a name for the branch and click the Create button. Now you're back to the older version of the project.

Xcode Discarded All Changes without commiting

I accidentally hit discard all changes without having "committed". It seems to have wiped all the info from the app when I open Xcode but when I go to the project file all the .swift files and icons are still there. I have tried what the other posts have said about all of the git commands but this seems to be different. Since discarding changes brought me to the starting part of the project but I still have all the files from before is there an alternative way I can restore my program?
Can't you just re-add the files in Xcode?
Xcode > File > Add files to...
... and reselect the .swift files / icons that you mentioned that are still there.

Xcode project renamed and now it is lost

I was trying to rename my Xcode project and I followed the apple developer guide and went to View -> Utilities -> Open file inspector and changed the name. Now the initial project only has the pods and the new project created won't run. Is there a way to restore it? I have been working on this project for months and would be devastated if it was lost.
would be devastated if it was lost
That's what version control is for (git).
But if you don't have a git commit to revert to, don't worry; there is a simple solution. Start a new empty project based on one of the built-in app templates and just migrate everything from your old project into that. No actual files have been deleted by whatever you did, so there should be no difficulty about this.

Xcode 4.2 does not commit files?

I have Xcode 4.2 and I was working ona a project, that was commited previously with - let;s call it - place A. Then I copied it on my disk to another place, made modifications and now I imported via Xcode Organizer whole new project into place B. But when I checked out project from place B I cannot commit any file. I select a file, choose commit, write comment and go. It looks ok, but in fact the status of this file is not changing, so I can without any warning make commits on and on... Is it problem with some project setting or what? I remember that in previous Xcode in project settings you could set svn location, but here I don't see anything like it.
I think you have not copied a folder .svn in the root of your Project - there are the meta-informations of SVN, without this infos SVN can not work. Just find and copy this folder from A to B and the issue will gone!

MainStoryboard disappeared after moving project folder

I just tried to make a copy of an X-code project (perhaps ironically, for back up purposes) by alt+dragging to another folder.
Instead I accidentally just dragged it and X-code complained about this (I know, I should've closed X-Code before attempting to copy the folder) so I moved it back immediately.
X-code insisted it either re-save or close, so I opted for close.
When I reopened it, my MainStoryboard was gone (red typeface in the explorer).
Anyone know if it's possible to retrieve it?
Not much help to anyone but switching the Mac on and off again restored the file, which was a nice surprise.
Are the files in the project directory?
If so, you can try to delete them from XCode and re-add them to the project.
It could a problem linked to the localization. You should try to remove any other langages.
Do you use any souce management tool (svn, git, snapshots or Time Machine)?
If so you can maybe take a look at it to retrieve a recent version of the files.

Resources