打开 XIB 文件后 Xcode 6.3 冻结/挂起
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/29544738/
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 6.3 freezes/hangs after opening XIB file
提问by picciano
After upgrading to Xcode 6.3 (release version), Xcode now freeze every time I open a XIB/Storyboard file that includes an IB_DESIGNABLE
view that uses a custom fontfor any projects and includes a custom font (not necessarily to have reference to that font in that XIB/Storyboard). The freeze occurs after opening the .xib file and then attempting to switch to any other file. Xcode hangs and must be force quit.
升级到 Xcode 6.3(发布版本)后,Xcode 现在每次打开包含IB_DESIGNABLE
视图的 XIB/Storyboard 文件时都会冻结使用自定义字体适用于任何项目并包含自定义字体(不一定要在该 XIB/故事板中引用该字体)。在打开 .xib 文件然后尝试切换到任何其他文件后会发生冻结。Xcode 挂起,必须强制退出。
I have opened a bug report with Apple. (Bug 20483867).
我已经打开了与 Apple 的错误报告。(错误 20483867)。
Right now, I have two work arounds.
现在,我有两个解决方法。
- Download and use Xcode 6.2 from Apple.
- Remove the IB_DESIGNABLE tags from the custom view header files.
- 从 Apple 下载并使用 Xcode 6.2。
- 从自定义视图头文件中删除 IB_DESIGNABLE 标签。
This is likely an Apple bug, but does anyone have a better work around or solution?
这可能是 Apple 的错误,但有没有人有更好的解决方法或解决方案?
采纳答案by Josh Brown
Xcode 6.3.1 fixes the problem with custom fonts and IB_DESIGNABLE
views in a Storyboard. Update via the Mac App Store, and you should be good.
Xcode 6.3.1 修复IB_DESIGNABLE
了 Storyboard 中自定义字体和视图的问题。通过 Mac App Store 更新,你应该很好。
回答by James Tang
I've already suggested an edit for a more accurate description.
我已经建议进行编辑以获得更准确的描述。
It only happens when your project contains a custom font.It'll freeze just by visiting any Storyboard/XIB that contains an IBDesignable custom view, not even referencing to that font in your Storyboard/XIB.
它仅在您的项目包含自定义字体时发生。只需访问包含 IBDesignable 自定义视图的任何 Storyboard/XIB,它就会冻结,甚至不引用 Storyboard/XIB 中的该字体。
My workaround is to use have an older version of Xcode also installed (Xcode 6.3 beta or Xcode 6.2) and use that to update your Interface Builder files, and never open it in 6.3.open those Storyboard/XIB in a new window in Xcode with option
+shift
+click
the file in the project tree.
我的解决方法是使用还安装了旧版本的 Xcode(Xcode 6.3 beta 或 Xcode 6.2)并使用它来更新您的 Interface Builder 文件,并且永远不要在 6.3 中打开它。使用option
+ shift
+click
项目树中的文件在Xcode 的新窗口中打开那些 Storyboard/XIB 。
Whenever you encounter the freeze, I use this command to clear the saved state just for that project.
每当您遇到冻结时,我都会使用此命令清除该项目的保存状态。
rm -rf YourProject.xcodeproj/project.xcworkspace/xcuserdata
rm -rf YourProject.xcodeproj/project.xcworkspace/xcuserdata
回答by picciano
Response from Apple: Link to Developer Forums on Apple
Apple 的回应:Apple上的开发者论坛链接
Thank you all for your reports. We are tracking this on our end and working hard to resolve it. Unfortunately we don't have a great workaround, but here are two options to get you going:
If Xcode is hanging on launch because a storyboard/XIB using a custom font/IBDesignable was previously open: remove the "UserInterfaceState.xcuserstate" file inside the xcodeproj of the project you are opening, it would be at a path like this: My App.xcodeproj/project.xcworkspace/xcuserdata/yourusername.xcuserdatad/UserInterfaceState.xcuserstate
If you really need to edit the storyboard/XIB file containing the custom font with Xcode 6.3:
- Make a copy of your storyboard/XIB file as a backup
- Open the storyboard/XIB file in a text editor
- Remove XML tags named "fontDescription" that reference your custom font, for example: . Removing this tag will revert the font to the standard system font.
- Make outlets to the objects using the custom font and at runtime set the font of those objects to your custom font, for example in an override of viewDidLoad or awakeFromNib on your view controller
IMPORTANT NOTE:we never recommend hand editing storyboard/XIB files. However we recognize this issue is preventing many of you from editing your documents and wanted to provide a workaround with the caveat that any hand editing may result in corruption of your document.
谢谢大家的报告。我们正在跟踪这个问题并努力解决它。不幸的是,我们没有很好的解决方法,但这里有两个选项可以帮助您:
如果 Xcode 在启动时挂起,因为使用自定义字体/IBDesignable 的情节提要/XIB 之前已打开:删除您正在打开的项目的 xcodeproj 中的“UserInterfaceState.xcuserstate”文件,它将位于如下路径:我的应用程序.xcodeproj/project.xcworkspace/xcuserdata/yourusername.xcuserdatad/UserInterfaceState.xcuserstate
如果您确实需要使用 Xcode 6.3 编辑包含自定义字体的故事板/XIB 文件:
- 复制您的故事板/XIB 文件作为备份
- 在文本编辑器中打开故事板/XIB 文件
- 删除引用您的自定义字体的名为“fontDescription”的 XML 标记,例如:删除此标记会将字体恢复为标准系统字体。
- 使用自定义字体制作对象的出口,并在运行时将这些对象的字体设置为您的自定义字体,例如在视图控制器上的 viewDidLoad 或awakeFromNib 的覆盖中
重要提示:我们从不建议手动编辑故事板/XIB 文件。但是,我们认识到这个问题会阻止你们中的许多人编辑您的文档,并希望提供一种解决方法,但需要注意的是,任何手动编辑都可能导致您的文档损坏。
回答by Denis Kildishev
Same problem for me. Removing IB_DESIGNABLE fixes the problem.. Going back to 6.2 doesn't work for me as I'm testing apps on device with iOS 8.3 - Xcode 6.2 can't run apps on devices with iOS 8.3 :(
对我来说同样的问题。删除 IB_DESIGNABLE 解决了问题.. 回到 6.2 对我不起作用,因为我正在使用 iOS 8.3 的设备上测试应用程序 - Xcode 6.2 无法在使用 iOS 8.3 的设备上运行应用程序:(
回答by KoCMoHaBTa
Another workaround is to change the file extensions to all of your font files and load the changed file names from Info.plist. This way you can keep IBDesignables and still use your custom fonts, but wont be able to see them in the Font Picker in Interface Builder.
另一种解决方法是将文件扩展名更改为所有字体文件,并从 Info.plist 加载更改后的文件名。通过这种方式,您可以保留 IBDesignables 并仍然使用您的自定义字体,但无法在 Interface Builder 的字体选择器中看到它们。
All custom fonts that were peviously set from Interface Builder will continue to work, but in order to change them or to set another custom fonts, you will have to do it either from code or to modify the Storyboard or Nib files from text editor in order to set the font name.
以前从 Interface Builder 设置的所有自定义字体将继续工作,但为了更改它们或设置另一个自定义字体,您必须从代码或从文本编辑器修改 Storyboard 或 Nib 文件中按顺序进行设置字体名称。
回答by Bart van Kuik
I don't have an answer but found out that simply force-quitting and restarting will re-launch Xcode in the exact same situation. To just be able to restart Xcode, remove the folder ~/Library/Saved Application State/com.apple.dt.Xcode.savedState
.
我没有答案,但发现简单地强制退出并重新启动将在完全相同的情况下重新启动 Xcode。为了能够重新启动 Xcode,请删除文件夹~/Library/Saved Application State/com.apple.dt.Xcode.savedState
.
回答by Christian A. Str?mmen
This bug has been fixed in the 6.4 Xcode beta that came out today. Go to the dev center and log in to download it.
这个错误已在今天发布的 6.4 Xcode 测试版中得到修复。转到开发中心并登录以下载它。
回答by O. Kurnenkov
Xcode 8.1 - if you have a view with Navigation (in my case it was top Bar opaque Navigation Bar), just try to set property "top Bar" to None.
Xcode 8.1 - 如果你有一个带有导航的视图(在我的例子中它是顶部栏不透明导航栏),只需尝试将属性“顶部栏”设置为无。
回答by LuisCien
@O. Kurnenkov's answer worked for me. It didn't have anything to do with IB_Designable nor custom fonts, Cocoapods, etc.
@O。Kurnenkov 的回答对我有用。它与 IB_Designable 或自定义字体、Cocoapods 等无关。
For some reason having an "Opaque Navigation Bar" causes the nib
file (it doesn't seem to affect storyboard
s) to constantly change y
position; this can be seen in the Size Inspector
where the y
position will flicker between 0 and 64. This is happening to me with Xcode 8.2 (8C38).
出于某种原因,“不透明导航栏”会导致nib
文件(它似乎不影响storyboard
s)不断改变y
位置;这可以Size Inspector
在y
位置将在 0 和 64 之间闪烁的位置中看到。这发生在我的 Xcode 8.2 (8C38) 上。
My guess here is that this causes Xcode to constantly update the layout thus draining resources and causing it to hang/freeze.
我的猜测是,这会导致 Xcode 不断更新布局,从而耗尽资源并导致它挂起/冻结。
The solution is to use any of the "Translucent" options, Inferred, or None.
解决方案是使用任何“半透明”选项、推断或无。
Hope this helps!
希望这可以帮助!
回答by user871177
As a workaround,I just commented out all the @IBDesignable markup in my handful of custom components that use this. When I did that, yes I lose ability to tweak the settings in Interface Builder, but it allowed me to at least open the .xib files w/out XCode crashing.
作为一种解决方法,我只是在使用它的少数自定义组件中注释掉了所有 @IBDesignable 标记。当我这样做时,是的,我失去了在 Interface Builder 中调整设置的能力,但它至少允许我打开 .xib 文件而没有 XCode 崩溃。
I will simply un-comment those @IBDesignable lines when Apple comes up w/ a fix.
当 Apple 提出修复程序时,我将简单地取消注释那些 @IBDesignable 行。