如何在 xcode 中恢复故事板?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/24715109/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do I recover a storyboard in xcode?
提问by Scott
I have a little bit of a situation here. A few days ago, I accidentally deleted my storyboard, so immediately went into my trash and dragged the storyboard back into the project. Everything worked fine. But then I just emptied my trash and the storyboard no longer appears to be in my project; the storyboard file is showing up red and when I click on it, nothing loads. To my dismay, I thought all was lost so I started building a new storyboard and connecting the classes, outlets and actions.
我这里有点情况。几天前,我不小心删除了我的故事板,所以立即进入我的垃圾箱,将故事板拖回项目中。一切正常。但后来我清空了我的垃圾箱,故事板似乎不再出现在我的项目中;故事板文件显示为红色,当我点击它时,没有加载任何内容。令我沮丧的是,我认为一切都失去了,所以我开始构建一个新的故事板并连接类、出口和行动。
I then went to build the project on the simulator, and it's building with the OLD storyboard. I thought it might just be loading it from memory so I deleted the app on the simulator and built the project again. Same thing again. So then I built it to my iPhone and somehow the old storyboard is still there even though I can't find it anywhere in my project.
然后我去在模拟器上构建项目,它是用旧的故事板构建的。我认为它可能只是从内存中加载它,所以我删除了模拟器上的应用程序并重新构建了项目。又是同样的事情。然后我将它构建到我的 iPhone 上,不知何故旧的故事板仍然存在,即使我在我的项目中的任何地方都找不到它。
What's going on here? Does this mean I'll be able to recover my storyboard?
这里发生了什么?这是否意味着我将能够恢复我的故事板?
Also, when I open the project inspector and go to Build Phases > Copy Bundle Resources, and right click on Storyboard.storyboard, and click show in finder, It shows my new storyboard.
另外,当我打开项目检查器并转到 Build Phases > Copy Bundle Resources,然后右键单击 Storyboard.storyboard,然后单击在 finder 中显示时,它会显示我的新故事板。
采纳答案by Nirav Bhatt
1 - There is a place in Derived Data
with following path:
1 - 有一个地方Derived Data
有以下路径:
/Users/<Your user name>/Library/Developer/Xcode/DerivedData/<Your App Name>/Build/Products/Debug-iphonesimulator/<app Name.app>
Browse to that location.
浏览到该位置。
2 - On your .app file, right click -> Show Package Contents.
2 - 在您的 .app 文件上,右键单击 -> 显示包内容。
3 - In resulting directory list, browse the folder Base.lproj
. Under that you are likely to find your old storyboard.
3 - 在结果目录列表中,浏览文件夹Base.lproj
。在此之下,您可能会找到旧的故事板。
If you have done Delete Derived Data
from XCode organizer, you are not likely to find anything up here. But fortunately, XCode doesn't delete it twice against your own wishes.
So try your luck.
如果您是Delete Derived Data
从 XCode 组织者那里完成的,那么您不太可能在这里找到任何东西。但幸运的是,XCode 不会违背您的意愿两次删除它。所以试试你的运气。
回答by Paraneetharan Saravanaperumal
I also faced same problem in Xcode 7.
我在 Xcode 7 中也遇到了同样的问题。
But when I copy and paste it from Derived Data
. I got
但是当我从Derived Data
. 我有
"Interface Builder cannot open compiled nibs"
“界面生成器无法打开已编译的笔尖”
So If you delete storyboard by reference. First, check your project folder (using the Finder). If it's there, you can drag it back into your project in Xcode, or you can use the “Add Files to …” menu option. that file is work perfectly.
所以如果你通过引用删除故事板。首先,检查您的项目文件夹(使用 Finder)。如果它在那里,您可以将它拖回到 Xcode 中的项目中,或者您可以使用“将文件添加到...”菜单选项。该文件是完美的工作。