xcode 9崩溃时,打开故事板

XCode 9 GM Candidate 1当前正在打开故事板时崩溃。

ProductBuild版本:9A235

UNCAUGHT EXCEPTION (NSInternalInconsistencyException): Could not find class named UIImage UserInfo: (null) Hints: 0: Replacement view is installing: <IBStoryboardCanvasViewController: 0x7fdf6d7f7d70 representing: (null)> 

对我来说,它是在我的应用程序中打开任何故事板或xib崩溃。 我已经创build了一个新的单视图应用程序项目,打开故事板没有问题,重新打开我自己的项目 – 它开始像往常一样打开故事板和xib。 可能是某种caching问题..

这里是我遇到的一个崩溃的细节:

 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: 

我经历过的另一次崩溃,并以同样的方式得到修复:

 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) 

我有同样的问题,但在我的情况下,它不是通过删除无钥匙解决。 正如Vlad Valentin所强调的那样,它与我在Storyboard中的UITabBarViewController有关。

这个问题,正如在Xcode崩溃报告中引发的错误所述:

 UNCAUGHT EXCEPTION (NSInternalInconsistencyException): Could not find class named UIImage 

与我已经分配给tabBar背景图像有关。 一旦我从Storyboard源代码中删除图像,我可以再次打开Interface Builder。

去掉:

 <tabBar key="tabBar" contentMode="scaleToFill" backgroundImage="Tabbar background" id="W28-zg-YXA"> 

当我尝试使用Interface Builder重新添加图像时,Xcode抛出了相同的exception。 我已经采取以编程方式加载图像。 希望这有助于,并将节省一些人不得不完全重新创build他们的UITabBarViewController的。

我遇到类似的问题。 在我的情况下,我发现它通过文件浏览器打开时一直崩溃,而通过快速打开( CMD + SHIFT + O )打开不会导致XCode崩溃。

这个问题是一个无钥匙标签(至less对我来说)

<nil key="simulatedBottomBarMetrics"/>

或更一般地说

<nil key="<generic_name>"/>

那有它的副本

<simulatedToolbarMetrics key="simulatedBottomBarMetrics"/>

或更一般地说

<<generic_name> key="generic_name"/>

删除所有这些解决了这个问题。

  1. 源代码的forms打开故事板
  2. search并删除: <nil key="simulatedBottomBarMetrics"/>或任何<nil key="<generic_name>"/> (用您的特定标签名称replace<generic_name>
  3. search并移除其计数器部分: <simulatedToolbarMetrics key="simulatedBottomBarMetrics"/>或任何<< generic_name > key="generic_name"/> (用您的特定标签名称replace<generic_name>
  4. 正常保存并打开故事板
  5. 请享用

编辑:

这个标签似乎是相关的,并在UITabBarController故事板源代码中 ,但是它们的对应分散在连接到UITabBarController UIViewControllers周围。 可以是一个,两个或更多的水平以下。

我find了解决scheme。 它从UITabBarViewController崩溃。

  1. 打开故事板作为源代码
  2. search你的UITabBarViewController
  3. 删除标签栏
  4. 打开故事板作为接口生成器
  5. 创build新的标签栏并连接您所需的根视图控制器

正如Michele Schillaci所说,你可以尝试删除一些视图控制器,并检查是否解决了这个问题。

有一个包含系统标签栏项目的标签栏已知的错误。 Xcode 9.1发行说明承认这一点,并提出一个解决方法:

界面生成器

configuration为故事板或xib中的系统项的UITabBarItem会导致构build失败。 (34197132)

解决方法 :在Interface Builder中将其configuration为自定义项目,然后将该选项卡栏项目重置为视图控制器的awakeFromNib方法中所需的系统项目。

我删除了<nil key ="....">但没有奏效。 所以我试过(来自@Vlad Valentin):

  1. 打开故事板作为源代码。
  2. searchtabBarController

      <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> 
  3. storyboardIdentifier="mainViewController"customClass="MainViewController"<connections>..</connections>对你很重要。 复制并粘贴它。

  4. 删除scene
  5. 现在,您可以使用Interface Builder打开故事板。
  6. 添加标签栏控制器(拖放并删除子视图控制器。)
  7. 去Stroyboard源代码和粘贴storyboardIdentifiercustomClassconnections

轻松修复:

只要在<tabBar key="tabBar" contentMode="scaleToFill" id="ytw-4N-0RV">上放置insetsLayoutMarginsFromSafeArea="NO" ,并从故事板源代码中删除所有<nil key ="....">

例如:

 <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"/> 

我取代了这个

 <tabBar key="tabBar" contentMode="scaleToFill" translucent="NO" backgroundImage="background_tabbar" selectionIndicatorImage="background_tabbar_item" id="Z9r-yE-1Zs"> 

在那

 <tabBar key="tabBar" contentMode="scaleToFill" id="Z9r-yE-1Zs"> 

而当我尝试打开故事板时,Xcode不再崩溃

所以我有一个问题,只要我在XCode 9中打开故事板,文件就被修改了(对XCode来说并不罕见),但是每当我运行带有Exception breakpoints的应用程序时,它都会崩溃。 从debugging器打开继续允许应用程序然后正常运行。

看看XCode在故事板文件中修改了什么,它在文件的顶部,在“scenes”xml元素之前,将它join:

 <customFonts key="customFonts"> <array key="GillSans.ttc"> <string>GillSans</string> <string>GillSans-Light</string> </array> </customFonts> 

删除这个停止了奇怪的崩溃问题,但修改故事板继续添加代码。看来解决scheme将是从故事板中删除所有自定义字体,并将其设置在代码中 – 或希望这只是一个奇怪的错误,将是在更高版本的XCode中修复。

我遇到了同样的问题:在Xcode 8中创build的故事板会挂在Xcode 9中。通过逐个导出视图(使用Editor / Refactor to Stoyboard – 一个我不知道存在的function,直到我这个问题)我发现有两个特定的视图导致Xcode挂起。

在这两个视图中,我向UITabBar添加了多个项目 – 左侧的button,右侧的灵活空间和button。 如果Xcode试图显示这个,它会挂起。 一旦看到这些“中毒”的观点,如果我快速点击任何其他故事板,它也会挂起。

因此,解决方法是在Xcode 8中打开项目,从TabBar中删除所有项目,删除任何派生数据文件夹,退出Xcode 8,加载Xcode 9,执行Product / Clean,如果幸运的话,会好起来的。

尝试打开另一个项目的“.storyboard”,然后返回到Xcode崩溃的项目!

我在Xcode 9.1(9B55)上遇到了一个确切的问题,那个项目昨天还好。 今天,当我试图打开任何“.storyboard / .xib”文件Xcode崩溃!

正如有人build议我删除所有“ <nil key=... ”标签内容。 这工作,但同时我打开了另一个项目的故事板。 然后,我恢复了所有的变化,并再次工作。

这似乎不是由“ <nil key=... ”标记内容引起的,而是由Xcode变为奇怪的状态引起的。