简体   繁体   English

打开故事板时xcode 9崩溃

[英]xcode 9 crash when open storyboard

XCode 9 GM Candidate 1 is currently crashing when opening a storyboard. 打开故事板时,XCode 9 GM Candidate 1正在崩溃。

ProductBuildVersion: 9A235 ProductBuildVersion:9A235

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

For me it was crashing on opening any storyboard or xib in my app. 对我来说,在我的应用程序中打开任何故事板或xib时崩溃了。 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. 我创建了一个新的单一视图应用程序项目,没有问题打开它的故事板,重新打开我自己的项目 - 它开始像往常一样打开故事板和xibs。 Probably a caching issue of some sort.. 可能是某种缓存问题..

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)

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. 正如Vlad Valentin强调的那样,它与我在Storyboard中的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 image I had assigned to the tabBar . 与我分配给tabBar背景图像有关。 Once I removed the image from the Storyboard source code, I could then open Interface Builder again. 从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. 当我尝试使用Interface Builder重新添加图像时,Xcode抛出了相同的异常。 I have resorted to loading the image programmatically. 我已经采用编程方式加载图像。 Hope this helps, and will save some people having to fully re-create their UITabBarViewController 's. 希望这会有所帮助,并且会节省一些人必须完全重新创建他们的UITabBarViewController

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崩溃。

The issue is a nil key tag (at least for my case) 问题是一个零关键标签(至少在我的情况下)

<nil key="simulatedBottomBarMetrics"/>

or more generally 或更一般地说

<nil key="<generic_name>"/>

That has its counterpart 这有它的对应物

<simulatedToolbarMetrics key="simulatedBottomBarMetrics"/>

or more generally 或更一般地说

<<generic_name> key="generic_name"/>

Removing all of them solves the issue. 删除所有这些解决了这个问题。

  1. Open the storyboard as Source Code 打开故事板作为源代码
  2. Search and remove: <nil key="simulatedBottomBarMetrics"/> or any <nil key="<generic_name>"/> (replace <generic_name> with your particular tag name) 搜索并删除: <nil key="simulatedBottomBarMetrics"/>或任何<nil key="<generic_name>"/> (将<generic_name>替换为您的特定标记名称)
  3. Search and remove their counter part: <simulatedToolbarMetrics key="simulatedBottomBarMetrics"/> or any << generic_name > key="generic_name"/> (replace <generic_name> with your particular tag name) 搜索并删除其计数器部分: <simulatedToolbarMetrics key="simulatedBottomBarMetrics"/>或任何<< generic_name > key="generic_name"/> (将<generic_name>替换为您的特定标记名称)
  4. Save and open your storyboard normally 正常保存并打开故事板
  5. Enjoy 请享用

EDIT: 编辑:

This tags seems to be related and are in the Storyboard Source Code of UITabBarController s however their counterparts are scattered around UIViewControllers connected to the UITabBarController . 这个标签似乎是相关的,并且在UITabBarControllerStoryboard源代码中 ,但它们的对应物分散在连接到UITabBarController UIViewControllers周围。 Can be one, two or more levels below. 可以是下面的一个,两个或更多级别。

I found a solution for my case. 我为我的案子找到了一个解决方案。 It was crashing from the UITabBarViewController. 它从UITabBarViewController崩溃了。

  1. Open the storyboard as source code 打开故事板作为源代码
  2. Search for your UITabBarViewController 搜索您的UITabBarViewController
  3. Remove the tab bar 删除标签栏
  4. Open storybard as Interface builder 打开storybard作为Interface builder
  5. Create new tab bar and connect the root view controllers you need 创建新选项卡栏并连接所需的根视图控制器

As Michele Schillaci said, you can try to remove some view controller and check if that solved the problem. 正如Michele Schillaci所说,您可以尝试删除一些视图控制器并检查是否解决了问题。

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 Interface Builder

A UITabBarItem configured as a system item in a storyboard or xib causes a build failure. 配置为故事板或xib中的系统项的UITabBarItem会导致构建失败。 (34197132) (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. 解决方法 :在Interface Builder中配置为自定义项,然后将选项卡栏项重置为视图控制器的awakeFromNib方法中的所需系统项。

I removed <nil key ="...."> but it didn't work. 我删除了<nil key ="....">但它没有用。 So i tried that (From @Vlad Valentin): 所以我试过(来自@Vlad Valentin):

  1. Open the storyboard as source code. 打开故事板作为源代码。
  2. Search for tabBarController 搜索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> 
  3. storyboardIdentifier="mainViewController" , customClass="MainViewController" and <connections>..</connections> are important for you. storyboardIdentifier="mainViewController"customClass="MainViewController"<connections>..</connections>对您很重要。 Copy and paste it. 复制并粘贴它。

  4. Remove scene . 删除scene
  5. Now you can open storyboard with Interface Builder. 现在,您可以使用Interface Builder打开故事板。
  6. Add Tab Bar Controller (Drag Drop and remove child view controller.) 添加标签栏控制器(拖放并删除子视图控制器。)
  7. Go Stroyboard source code and paste storyboardIdentifier , customClass and connections . Go Stroyboard源代码并粘贴storyboardIdentifiercustomClassconnections

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. 只需在<tabBar key="tabBar" contentMode="scaleToFill" id="ytw-4N-0RV">insetsLayoutMarginsFromSafeArea="NO"<tabBar key="tabBar" contentMode="scaleToFill" id="ytw-4N-0RV">从故事板源代码中删除所有<nil key ="....">

Eg: 例如:

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

I got this problem too. 我也遇到了这个问题。 Crash(rainbow ball rotating) when I click my storyboard file in Xcode of my working project. 当我在我的工作项目的Xcode中单击我的故事板文件时崩溃(彩虹球旋转)。 It's happened even if I create a new single view project. 即使我创建了一个新的单一视图项目,也会发生这种情况。

For me, I restart my Mac Book to be a workaround solution. 对我来说,我重启我的Mac Book是一个解决方案。

Hope this can fix ur problem. 希望这可以解决你的问题。

I found that the previously installed versions of XCode were the root of the problem. 我发现以前安装的XCode版本是问题的根源。 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. 我以为我只安装了一个版本但是在右键单击一个XCode项目文件时,我看到在“打开方式......”下,有很多版本。 There were old beta versions of XCode 9, as well as various versions of the stable release and even XCode 8. 有旧的beta版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. 这些版本都不能在我的mac的Applications目录中找到,所以我意识到它们在Downloads目录中处于休眠状态。 What I did was delete all of them and boom, storyboard not freezing XCode 9.3 anymore. 我做的是删除所有这些和繁荣,故事板不再冻结XCode 9.3。

I replaced this 我取代了这个

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

on that 在那

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

and Xcode doesn't crash anymore when I try to open the storyboard 当我尝试打开故事板时,Xcode不再崩溃

So I had an issue whereby as soon as I opened a storyboard in XCode 9 the file was modified (not unusual for XCode) - but then whenever I ran the app with Exception breakpoints enabled it crashed. 所以我遇到了一个问题,一旦我在XCode 9中打开一个故事板,文件就被修改了(对于XCode来说并不罕见) - 但是每当我运行带有异常断点的应用程序时,它就会崩溃。 Hitting continue from the debugger allowed the app to then run normally. 从调试器继续点击允许应用程序正常运行。

Looking at what XCode has modified in the storyboard file, it turned that at the top of the file, before the 'scenes' xml element, it was adding: 看看XCode在故事板文件中修改了什么,它在文件的顶部,在'scenes'xml元素之前,它添加了:

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

Removing this stopped the weird crash issue, but modifying the storyboard keeps adding the code back in. It appears the solution would be to remove all custom fonts from the storyboard and set them in code - or hope this is just a weird bug which will be fixed in a later XCode version. 删除它阻止了奇怪的崩溃问题,但是修改故事板会不断添加代码。似乎解决方案是从故事板中删除所有自定义字体并在代码中设置它们 - 或者希望这只是一个奇怪的错误,它将是在稍后的XCode版本中修复。

I was having the same issue: a storyboard created in Xcode 8 would hang in Xcode 9. After taking my Storyboard apart by exporting the views one by one (using Editor / Refactor to Stoyboard - a feature I didn't know existed until I was struck by this issue) I found that two specific views were causing Xcode to hang. 我遇到了同样的问题:在Xcode 8中创建的故事板将在Xcode 9中挂起。通过逐个导出视图将我的故事板分开(使用编辑器/重构器到Stoyboard - 我不知道的一个功能,直到我是受到这个问题的影响)我发现两个特定的视图导致Xcode挂起。

In both these views, I had added more than one item to a UITabBar - a button on the left, a flexible space and a button on the right. 在这两个视图中,我向UITabBar添加了多个项目 - 左侧的按钮,右侧的灵活空间和按钮。 If Xcode tried to display this, it would hang. 如果Xcode试图显示它,它会挂起。 If I quickly clicked to any other Storyboard once these "poisoned" views were seen, it would also hang. 如果我看到这些“中毒”视图后我快速点击任何其他故事板,它也会挂起。

The solution is therefore to open the project in Xcode 8, remove all but one item from the TabBar, delete any Derived Data folders, quit Xcode 8, load Xcode 9, do a Product / Clean, and if you're lucky, you'll be good to go. 因此,解决方案是在Xcode 8中打开项目,从TabBar中删除除一个项目之外的所有项目,删除任何Derived Data文件夹,退出Xcode 8,加载Xcode 9,执行产品/清洁,如果幸运,那么你'我会好的。

Try to open another project's ".storyboard" and then go back to the project which is making Xcode crash! 尝试打开另一个项目的“.storyboard”,然后回到正在使Xcode崩溃的项目!

I had this exact problem with Xcode 9.1 (9B55) on a project which was ok yesterday. Xcode 9.1(9B55)在昨天没问题的项目中遇到了这个问题。 Today when I tried to open any ".storyboard/.xib" file Xcode was crashing! 今天当我试图打开任何“.storyboard / .xib”文件时,Xcode崩溃了!

As some people suggested I removed all " <nil key=... " tag contents. 有些人建议我删除所有“ <nil key=... ”标签内容。 It worked but meanwhile I had opened another project's storyboard. 它工作,但同时我打开了另一个项目的故事板。 Then I restored all my changes and it worked again. 然后我恢复了所有的更改,它再次起作用。

This seems not caused by the " <nil key=... " tag contents but by some weird state in which Xcode becomes. 这似乎不是由“ <nil key=... ”标签内容引起的,而是由Xcode变为的一些奇怪状态引起的。

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

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