简体   繁体   English

如何从 iOS 应用程序中删除未使用的故事板?

[英]How to remove unused storyboard from iOS app?

How do I remove a storyboard from an iOS app?如何从 iOS 应用程序中删除故事板?

I had an older app that I added a new universal storyboard and want to remove the old iPhone- and iPad-specific storyboards.我有一个旧的应用程序,我添加了一个新的通用故事板,并想删除旧的 iPhone 和 iPad 特定的故事板。

I tried just deleting them and the app will not compile after a clean and rebuild.我尝试删除它们,并且在清理和重建后应用程序将无法编译。 I get an error that the iPhone storyboard cannot be found.我收到一个错误,提示无法找到 iPhone 故事板。

I did a search for the iPhone storyboard but do not see any references.我搜索了 iPhone 故事板,但没有看到任何参考资料。

I had to revert my code back to having the unwanted storyboards.我不得不将我的代码恢复为拥有不需要的故事板。

Could a link from the old storyboard to a ViewController class be causing this?从旧故事板到 ViewController 类的链接会导致这种情况吗?

Here's my current storyboards showing the new launch and universal and the 2 old ones.这是我目前的故事板,显示了新发布和通用版以及 2 个旧版。 当前故事板显示 2 个不需要的旧故事板

I checked my targets and they don't reference the old storyboards any more.我检查了我的目标,他们不再引用旧的故事板。

在此处输入图片说明

在此处输入图片说明

Per Reinier's comments I have done this and still get a build error if I delete the old storyboard files from disk.根据 Reinier 的评论,我已经这样做了,如果我从磁盘中删除旧的故事板文件,仍然会出现构建错误。

在此处输入图片说明

So, I finally figured out the problem and am answering my own question for anyone else stuck in this situation.所以,我终于找到了问题所在,并且正在为陷入这种情况的其他人回答我自己的问题。

I knew there had to be some reference to the storyboards somewhere I was not seeing the my normal all files search in Xcode.我知道必须有一些对故事板的引用,我在 Xcode 中没有看到我正常的所有文件搜索。

I was right.我是对的。 The issue was the .pbxproj file which is within the .xcodeproj bundle.问题是 .xcodeproj 包中的 .pbxproj 文件。

I stumbled across this file while doing a GIT checkin comparison to see if there was some reference I was not finding by searching within Xcode.我在进行 GIT 签入比较时偶然发现了这个文件,以查看是否有一些我没有通过在 Xcode 中搜索找到的参考。 Xcode does not appear to search within this file. Xcode 似乎不会在此文件中进行搜索。

The .pbxproj file had several references to the old, unwanted storyboards like this: .pbxproj 文件多次引用旧的、不需要的故事板,如下所示:

D7DB80AD191BEAC900114581 /* MainStoryboard_iPad.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = D7DB8057191BEAC900114581 /* MainStoryboard_iPad.storyboard */; };
D7DB80AE191BEAC900114581 /* MainStoryboard_iPhone.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = D7DB8059191BEAC900114581 /* MainStoryboard_iPhone.storyboard */; };

They were all over the place in this file.他们在这个文件中无处不在。

I just went in and deleted all references to them.我刚刚进去并删除了对它们的所有引用。

I can clean and build the project without issue now.我现在可以毫无问题地清理和构建项目。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM