Recovering Accidental Storyboard Deletion

前端 未结 9 614
[愿得一人]
[愿得一人] 2020-12-20 11:56

I tried looking for the answer but didn\'t find it.

I accidentally deleted my storyboard in XCode4. Is there anyway that I can retrieve it? I looked in the trash ca

相关标签:
9条回答
  • 2020-12-20 12:39

    Even if you deleted your main story board, it would be there inside the folder called Base.lProj
    (This folder will be in the folder where your source and header files lie in the normal case.)

    So go to Xcode. Right click in the Project navigator in the left side tab and add these files to the project again.

    0 讨论(0)
  • 2020-12-20 12:46

    I just did the same. It was pretty easy to recover if you were using git (and there was not much change from the last commit).

    All you have to do is to restore your project.pbxproj file. Try git diff your .xcodeproj/project.pbxproj

    Once you confirm that restoring that file will save your storyboard (since you will find deleted lines around MainStoryboard), run this simple command:

    git checkout project.pbxproj
    

    If you made some change to the project (like adding files) since the last commit, you will find some added lines as well. Save them by running git diff before above command.

    0 讨论(0)
  • 2020-12-20 12:48

    If it popped up that means you can find it in your project folder. Just look in /projectName/projectName/Base.lproj. The storyboard is there. You can drag it into Xcode and its as good as new.

    0 讨论(0)
  • 2020-12-20 12:51

    If you really deleted the file (check in the file system, not just in XCode, see Liam's answer below for the location) and it's not in the trash, there are (afaik) really only two options;

    • TimeMachine if you have that running may have a good copy.
    • An undelete utility like Disk Drill or MacKeeper

    When undeleting, the more you use your disk after deleting a file, the less chance of recovery, so if you're really serious, you should install the program on another Mac and move the disk to that for recovery so that you won't overwrite anything.

    0 讨论(0)
  • 2020-12-20 12:51

    I had the same problem, I localized my storyboard and and failed at checking the wright option that leaded to only one storyboard.string file and my original storyboard was deleted by xcode. Hopefully, the original storyboard file was put un the trash so I was able to restore it. Perhaps now the new XCode 8 version puts the file int the trash by default.

    0 讨论(0)
  • 2020-12-20 12:51

    If you have committed before that happened, you can go old commit and copy storyboard's source code, and then you can create new storyboard and paste this code on it.

    0 讨论(0)
提交回复
热议问题