打开故事板时 xcode 9 崩溃
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/46311398/
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
xcode 9 crash when open storyboard
提问by Michele Schillaci
XCode 9 GM Candidate 1 is currently crashing when opening a storyboard.
XCode 9 GM Candidate 1 当前在打开故事板时崩溃。
ProductBuildVersion: 9A235
产品构建版本:9A235
UNCAUGHT EXCEPTION (NSInternalInconsistencyException): Could not find class named UIImage
UserInfo: (null)
Hints:
0: Replacement view is installing: <IBStoryboardCanvasViewController: 0x7fdf6d7f7d70 representing: (null)>
回答by pckill
For me it was crashing on opening any storyboard or xib in my app. I have created a new single view app project, opened its storyboard without a problem, reopened my own project - and it started opening storyboards and xibs as usual. Probably a caching issue of some sort..
对我来说,它在我的应用程序中打开任何故事板或 xib 时崩溃。我创建了一个新的单视图应用程序项目,没有问题地打开了它的故事板,重新打开了我自己的项目 - 它开始像往常一样打开故事板和 xib。可能是某种缓存问题..
Here are the details of a crash I was experiencing:
以下是我遇到的崩溃的详细信息:
Crashed Thread: 0 Dispatch queue: com.apple.main-thread
Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Exception Note: EXC_CORPSE_NOTIFY
Application Specific Information:
Sending _openAs: to <IDEDocumentController: 0x7f944580a970> from <NSMenuItem: 0x7f94249528d0 Interface Builder - Storyboard>
ProductBuildVersion: 9A235
ASSERTION FAILURE in /Library/Caches/com.apple.xbs/Sources/IDEInterfaceBuilder/IDEInterfaceBuilder-13196/InterfaceBuilderKit/IssueProvider/IBIssueProvider.m:72
Details: castedInstance should be an instance inheriting from IBDocument, but it is IDEPegasusSourceEditor.SourceCodeDocument
Object: <IBIssueProvider: 0x7f94366a73d0>
Method: -updatedIssuesForDocument:
Another crash that I have experienced, and that got fixed the same way:
我经历过的另一个崩溃,以同样的方式修复:
Crashed Thread: 0 Dispatch queue: com.apple.main-thread
Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Exception Note: EXC_CORPSE_NOTIFY
Application Specific Information:
Sending openClickedNavigableItemAction: to <IDEStructureNavigator: 0x7ff718acde20 representing: <DVTExtension 0x7ff70acf22e0: Structure Navigator (Xcode.IDEKit.Navigator.Structure) v0.1 from com.apple.dt.IDEKit>> from <IDENavigatorOutlineView: 0x7ff7169ba340>
ProductBuildVersion: 9A235
ASSERTION FAILURE in /Library/Caches/com.apple.xbs/Sources/IDEFrameworks/IDEFrameworks-13247/IDEKit/Editor/IDEEditorContext.m:1935
Details: Unexpected document in IDEDocumentController:<IBXIBDocument: 0x7ff6fb013a00>( 0 -[IDEEditorDocument init] (in IDEKit)
回答by Peza
I had the same issue, but in my case it was not solved by removing nil keys. As highlighted by Vlad Valentin, it was related to a UITabBarViewController
I had in my Storyboard.
我有同样的问题,但就我而言,它没有通过删除 nil 键来解决。正如 Vlad Valentin 所强调的那样,它与UITabBarViewController
我在故事板中的一个有关。
The issue, as stated in the error thrown in the Xcode crash report:
问题,如 Xcode 崩溃报告中抛出的错误所述:
UNCAUGHT EXCEPTION (NSInternalInconsistencyException): Could not find class named UIImage
related to a background imageI had assigned to the tabBar
. Once I removed the image from the Storyboard source code, I could then open Interface Builder again.
相关的背景图片我已经分配给tabBar
。从 Storyboard 源代码中删除图像后,我可以再次打开 Interface Builder。
Remove:
消除:
<tabBar key="tabBar" contentMode="scaleToFill" backgroundImage="Tabbar background" id="W28-zg-YXA">
When I tried re-adding the image using Interface Builder, Xcode threw the same exception. I have resorted to loading the image programmatically. Hope this helps, and will save some people having to fully re-create their UITabBarViewController
's.
当我尝试使用 Interface Builder 重新添加图像时,Xcode 抛出了相同的异常。我已经求助于以编程方式加载图像。希望这会有所帮助,并且可以节省一些人必须完全重新创建他们的UITabBarViewController
's 。
回答by Dermot
I'm getting a similar issue. In my case, I've found that it consistently crashes when opening via the file explorer, whereas opening via Open Quickly (CMD+SHIFT+O) does not cause XCode to crash.
我遇到了类似的问题。就我而言,我发现它始终崩溃通过文件浏览器时打开,而通过迅速打开开口(CMD+ SHIFT+ O)不会导致的XCode崩溃。
回答by victor.vasilica
The issue is a nil key tag (at least for my case)
问题是一个 nil 键标签(至少在我的情况下)
<nil key="simulatedBottomBarMetrics"/>
<nil key="simulatedBottomBarMetrics"/>
or more generally
或更一般地
<nil key="<generic_name>"/>
<nil key="<generic_name>"/>
That has its counterpart
那有它的对应物
<simulatedToolbarMetrics key="simulatedBottomBarMetrics"/>
<simulatedToolbarMetrics key="simulatedBottomBarMetrics"/>
or more generally
或更一般地
<<generic_name> key="generic_name"/>
<<generic_name> key="generic_name"/>
Removing all of them solves the issue.
删除所有这些可以解决问题。
- Open the storyboard as Source Code
- Search and remove:
<nil key="simulatedBottomBarMetrics"/>
or any<nil key="<generic_name>"/>
(replace<generic_name>
with your particular tag name) - Search and remove their counter part:
<simulatedToolbarMetrics key="simulatedBottomBarMetrics"/>
or any<< generic_name > key="generic_name"/>
(replace<generic_name>
with your particular tag name) - Save and open your storyboard normally
- Enjoy
- 打开故事板作为源代码
- 搜索并删除:
<nil key="simulatedBottomBarMetrics"/>
或任何<nil key="<generic_name>"/>
(替换<generic_name>
为您的特定标签名称) - 搜索并删除他们的对应部分:
<simulatedToolbarMetrics key="simulatedBottomBarMetrics"/>
或任何<< generic_name > key="generic_name"/>
(替换<generic_name>
为您的特定标签名称) - 正常保存并打开故事板
- 享受
EDIT:
编辑:
This tags seems to be related and are in the Storyboard Source Codeof UITabBarController
s however their counterparts are scattered around UIViewControllers
connected to the UITabBarController
. Can be one, two or more levels below.
这个标签似乎是相关的并且在s的故事板源代码中,UITabBarController
但是它们的对应物分散在UIViewControllers
连接到UITabBarController
. 可以是一个、两个或更多个级别。
回答by Vlad Valentin
I found a solution for my case. It was crashing from the UITabBarViewController.
我为我的案例找到了解决方案。它是从 UITabBarViewController 崩溃的。
- Open the storyboard as source code
- Search for your UITabBarViewController
- Remove the tab bar
- Open storybard as Interface builder
- Create new tab bar and connect the root view controllers you need
- 打开故事板作为源代码
- 搜索您的 UITabBarViewController
- 移除标签栏
- 打开 storybard 作为界面构建器
- 创建新的标签栏并连接你需要的根视图控制器
As Michele Schillaci said, you can try to remove some view controller and check if that solved the problem.
正如 Michele Schillaci 所说,您可以尝试删除一些视图控制器并检查是否解决了问题。
回答by matt
There is a known bug with tab bars containing system tab bar items. The Xcode 9.1 release notes acknowledge this, and suggest a workaround:
包含系统标签栏项目的标签栏存在一个已知错误。Xcode 9.1 发行说明承认这一点,并提出了一个解决方法:
Interface Builder
A UITabBarItem configured as a system item in a storyboard or xib causes a build failure. (34197132)
Workaround: Configure as a custom item in Interface Builder, then reset the tab bar item to the desired system item in the
awakeFromNib
method of the view controller.
界面生成器
配置为故事板或 xib 中的系统项的 UITabBarItem 会导致构建失败。(34197132)
解决方法:在 Interface Builder 中配置为自定义项,然后
awakeFromNib
在视图控制器的方法中将选项卡栏项重置为所需的系统项。
回答by John
I got this problem too. Crash(rainbow ball rotating) when I click my storyboard file in Xcode of my working project. It's happened even if I create a new single view project.
我也遇到了这个问题。当我在我的工作项目的 Xcode 中单击我的故事板文件时崩溃(彩虹球旋转)。即使我创建了一个新的单一视图项目,它也会发生。
For me, I restart my Mac Book to be a workaround solution.
对我来说,我重新启动我的 Mac Book 作为解决方案。
Hope this can fix ur problem.
希望这可以解决您的问题。
回答by AppreciateIt
I found that the previously installed versions of XCode were the root of the problem. I thought I only had one version installed but upon right-clicking an XCode project file, I saw that under 'Open With..', there were tons of versions. There were old beta versions of XCode 9, as well as various versions of the stable release and even XCode 8.
我发现以前安装的 XCode 版本是问题的根源。我以为我只安装了一个版本,但是在右键单击 XCode 项目文件时,我看到在“打开方式..”下有很多版本。有旧的 XCode 9 测试版,以及稳定版本甚至 XCode 8 的各种版本。
None of these versions could be found in my mac's Applications directory, so I realized that they were dormant in the Downloads directory. What I did was delete all of them and boom, storyboard not freezing XCode 9.3 anymore.
在我的 mac 应用程序目录中找不到这些版本,所以我意识到它们在下载目录中处于休眠状态。我所做的是删除所有这些并且繁荣,故事板不再冻结 XCode 9.3。
回答by a.u.b
I removed <nil key ="....">
but it didn't work. So i tried that (From @Vlad Valentin):
我删除了,<nil key ="....">
但没有用。所以我试过了(来自@Vlad Valentin):
- Open the storyboard as source code.
Search for
tabBarController
<scene sceneID="RIF-kY-Kwk"> <objects> <tabBarController storyboardIdentifier="mainViewController" id="p5V-Jj-erc" customClass="MainViewController" customModule="yourModule" customModuleProvider="target" sceneMemberID="viewController"> <tabBar key="tabBar" contentMode="scaleToFill" insetsLayoutMarginsFromSafeArea="NO" id="kWD-Cd-EAU"> <rect key="frame" x="0.0" y="0.0" width="375" height="49"/> <autoresizingMask key="autoresizingMask"/> <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/> </tabBar> <connections> <segue destination="FQU-DF-g8S" kind="relationship" relationship="viewControllers" id="wf7-sS-3aP"/> <segue destination="cVl-bj-mqD" kind="relationship" relationship="viewControllers" id="A5l-iP-1pv"/> <segue destination="yE9-HB-Hqo" kind="relationship" relationship="viewControllers" id="U4m-N7-DeC"/> <segue destination="PmG-7U-DMm" kind="relationship" relationship="viewControllers" id="u4J-Y7-Z51"/> </connections> </tabBarController> <placeholder placeholderIdentifier="IBFirstResponder" id="APY-5z-hrA" userLabel="First Responder" sceneMemberID="firstResponder"/> </objects> <point key="canvasLocation" x="-3126" y="1236"/> </scene>
storyboardIdentifier="mainViewController"
,customClass="MainViewController"
and<connections>..</connections>
are important for you. Copy and paste it.- Remove
scene
. - Now you can open storyboard with Interface Builder.
- Add Tab Bar Controller (Drag Drop and remove child view controller.)
- Go Stroyboard source code and paste
storyboardIdentifier
,customClass
andconnections
.
- 打开故事板作为源代码。
搜索
tabBarController
<scene sceneID="RIF-kY-Kwk"> <objects> <tabBarController storyboardIdentifier="mainViewController" id="p5V-Jj-erc" customClass="MainViewController" customModule="yourModule" customModuleProvider="target" sceneMemberID="viewController"> <tabBar key="tabBar" contentMode="scaleToFill" insetsLayoutMarginsFromSafeArea="NO" id="kWD-Cd-EAU"> <rect key="frame" x="0.0" y="0.0" width="375" height="49"/> <autoresizingMask key="autoresizingMask"/> <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/> </tabBar> <connections> <segue destination="FQU-DF-g8S" kind="relationship" relationship="viewControllers" id="wf7-sS-3aP"/> <segue destination="cVl-bj-mqD" kind="relationship" relationship="viewControllers" id="A5l-iP-1pv"/> <segue destination="yE9-HB-Hqo" kind="relationship" relationship="viewControllers" id="U4m-N7-DeC"/> <segue destination="PmG-7U-DMm" kind="relationship" relationship="viewControllers" id="u4J-Y7-Z51"/> </connections> </tabBarController> <placeholder placeholderIdentifier="IBFirstResponder" id="APY-5z-hrA" userLabel="First Responder" sceneMemberID="firstResponder"/> </objects> <point key="canvasLocation" x="-3126" y="1236"/> </scene>
storyboardIdentifier="mainViewController"
,customClass="MainViewController"
并且<connections>..</connections>
对您很重要。复制并粘贴它。- 删除
scene
。 - 现在您可以使用 Interface Builder 打开故事板。
- 添加标签栏控制器(拖放并删除子视图控制器。)
- 转到 Stroyboard 源代码并粘贴
storyboardIdentifier
,customClass
和connections
.
回答by Ernesto Araujo
Easy fix:
轻松修复:
Just put insetsLayoutMarginsFromSafeArea="NO"
on <tabBar key="tabBar" contentMode="scaleToFill" id="ytw-4N-0RV">
and remove all <nil key ="....">
from your storyboard source code.
只要把insetsLayoutMarginsFromSafeArea="NO"
上<tabBar key="tabBar" contentMode="scaleToFill" id="ytw-4N-0RV">
,并删除所有<nil key ="....">
从你的故事板的源代码。
E.g:
例如:
<tabBarController id="mhN-Gc-eXK" sceneMemberID="viewController" restorationIdentifier="tabbar" storyboardIdentifier="tabbar" customClass="TabbarMainViewController">
<tabBar key="tabBar" contentMode="scaleToFill" insetsLayoutMarginsFromSafeArea="NO" id="ytw-4N-0RV">
<rect key="frame" x="0.0" y="0.0" width="320" height="49"/>