ios 界面生成器 - 无法从路径加载设计(空)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/28391112/
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
Interface Builder - Failed to load designables from path (null)
提问by Jake
I have some custom controls I have created and I'm them using in a new project. However, I keep getting errors in interface builder:
我创建了一些自定义控件,并将它们用于新项目中。但是,我在界面构建器中不断出错:
Failed to update auto layout status: Failed to load designables from path (null)
or
或者
Failed to render instance of <control>: Failed to load designables from path (null)
I've tested out the controls in another project and they seem to render correctly in interface builder, but I cannot get them to work in the current project. What causes this error and how might I fix it?
我在另一个项目中测试了控件,它们似乎在界面构建器中正确呈现,但我无法让它们在当前项目中工作。导致此错误的原因是什么,我该如何解决?
Thanks in advance...
提前致谢...
回答by i89
I had the same issue. I use cocoapods and there is a pod which uses designables. So the trick was to add 'use_frameworks!' to the Podfile. do a 'pod update' reopen the xcode project and the error message shouldn't show up.
我遇到过同样的问题。我使用 cocoapods 并且有一个使用可设计的 pod。所以诀窍是添加'use_frameworks!' 到 Podfile。执行 'pod update' 重新打开 xcode 项目,错误消息不应该出现。
回答by Anthony Taylor
Edit**
编辑**
Open Xcode (but do not open your project) and click on Window (second from the right)
打开 Xcode(但不要打开您的项目)并单击 Window(从右数第二个)
Click Organizer and make sure you're on Projects, then delete all derived data. Close out Xcode and then reopen your project and let Xcode re-index your files and see if that clears up the issue
单击管理器并确保您在项目上,然后删除所有派生数据。关闭 Xcode,然后重新打开您的项目,让 Xcode 重新索引您的文件,看看是否能解决问题
回答by John Jacecko
I'm running Xcode 7.3, and got the error to magically disappear by following these steps that, in the end, left my project in the exact state that it was prior to following these steps (i.e. a net zero change to anything):
我正在运行 Xcode 7.3,并通过执行以下步骤使错误神奇地消失,最终使我的项目处于执行这些步骤之前的确切状态(即对任何内容进行净零更改):
- Add 'use_frameworks!' (without the apostrophes, of course) to your podfile
- Open up a terminal window
- cd to your project's root dir
- Run 'pod install' from the command line
- Remove the 'use_frameworks!' from your podfile
- Run 'pod install' again
- Try building again and see if that fixes the error; it did for me
- 添加“use_frameworks!” (当然没有撇号)到你的 podfile
- 打开终端窗口
- cd 到你项目的根目录
- 从命令行运行“pod install”
- 删除“use_frameworks!” 从你的 podfile
- 再次运行“pod install”
- 再次尝试构建,看看是否修复了错误;它对我有用
Looks like one of those occasional Xcode snags that we've all seen before, especially when you're in a hurry to get something else done.
看起来像是我们以前都见过的那些偶尔出现的 Xcode 障碍之一,尤其是当您急于完成其他事情时。
回答by JBarros35
If previous solutions didn't works for you, try adding to your target pod inherit! :search_paths
如果以前的解决方案不适合您,请尝试添加到您的目标 pod inherit! :search_paths
Sample
样本
target 'my-app-target' do
use_frameworks!
inherit! :search_paths
end
After that do a pod update as suggested before.
之后,按照之前的建议进行 pod 更新。
回答by Will Clarke
I don't use CocoaPods, but I do use a in-house framework that contains IBDesignable items, and was also experiencing this problem. I cleaned, deleted the Derived Data from my main project, and restarted Xcode, but that didn't seem to fix it. To resolve it, I had to go to Window > Projects, select the framework project (not the project that used the framework, but rather the framework project itself), and delete the Derived Data. So, full steps:
我不使用 CocoaPods,但我确实使用了一个包含 IBDesignable 项目的内部框架,并且也遇到了这个问题。我清理、删除了主项目中的派生数据,并重新启动了 Xcode,但这似乎并没有解决它。要解决它,我必须转到“窗口”>“项目”,选择框架项目(不是使用框架的项目,而是框架项目本身),然后删除派生数据。所以,完整的步骤:
- Product menu > Clean
- Hold down Option > Product menu > Clean Build Folder... > Clean
- Window menu > Projects > Choose my Framework project > Delete Derived Data
- Window menu > Projects > Choose my main project > Delete Derived Data
- Quit Xcode
- Restart Xcode
- 产品菜单 > 清洁
- 按住 Option > Product 菜单 > Clean Build Folder... > Clean
- 窗口菜单 > 项目 > 选择我的框架项目 > 删除派生数据
- 窗口菜单 > 项目 > 选择我的主项目 > 删除派生数据
- 退出 Xcode
- 重启Xcode
Repeat step 3 for any and all framework projects that have IBDesignables and may be causing the errors.
对任何和所有具有 IBDesignables 并且可能导致错误的框架项目重复步骤 3。
回答by pjuzeliunas
I had the same issue on non-CocoaPods project with custom IBDesignable
views. Apparently, it's an Xcode bug. Steps in this answerhelped me to resolve the problem. In short:
我在带有自定义IBDesignable
视图的非 CocoaPods 项目上遇到了同样的问题。显然,这是一个 Xcode 错误。这个答案中的步骤帮助我解决了这个问题。简而言之:
- Quit Xcode.
- Kill all processes named
Interface Builder Cocoa Touch Tool
on your machine. - Start Xcode again.
- 退出 Xcode。
- 杀死
Interface Builder Cocoa Touch Tool
在您的机器上命名的所有进程。 - 再次启动Xcode。
回答by PeiweiChen
This issue fixed in the latest version of Cocoapods
此问题已在最新版本的 Cocoapods 中修复
To install,simply run:
要安装,只需运行:
[sudo] gem install cocoapods --pre
In order to fix the Error: "failed to load designables from path (null)":
为了修复错误:“无法从路径(空)加载可设计项”:
use_frameworks!
pod '****'
end
Add use_frameworks!
to you Podfile
添加use_frameworks!
到您的 Podfile
Find more:Live Rendering a custom component using IB_DESIGNABLE from a pod dependency
回答by Antzi
The issues was that IB_DESIGNABLE from cocoapods are not linked correctly when interface builder render your views.
问题是当界面构建器呈现您的视图时,来自 cocoapods 的 IB_DESIGNABLE 没有正确链接。
The use_frameworks!
trick should do it but for me it was just a bit too much effort to migrate the code.
这个use_frameworks!
技巧应该可以做到,但对我来说,迁移代码有点费力。
My trick was to subclass every IB_DESIGNABLEview I used in the storyboard that came straight from the pods. Solved the errors.
我的技巧是将我在情节提要中使用的每个 IB_DESIGNABLE视图子类化,这些视图直接来自 pod。解决了错误。
回答by Rafael Machado
There's a very handy trick you can do to debug live rendering.
您可以使用一个非常方便的技巧来调试实时渲染。
1) Add this extension to your project:
1) 将此扩展添加到您的项目中:
extension UIView {
public func liveDebugLog(message: String) {
#if !(TARGET_OS_IPHONE)
let logPath = "/tmp/XcodeLiveRendering.log"
if !NSFileManager.defaultManager().fileExistsAtPath(logPath) {
NSFileManager.defaultManager().createFileAtPath(logPath, contents: NSData(), attributes: nil)
}
var fileHandle = NSFileHandle(forWritingAtPath: logPath)
fileHandle.seekToEndOfFile()
let date = NSDate()
let bundle = NSBundle(forClass: self.dynamicType)
let application: AnyObject = bundle.objectForInfoDictionaryKey("CFBundleName")
let data = "\(date) \(application) \(message)\n".dataUsingEncoding(NSUTF8StringEncoding, allowLossyConversion: true)
fileHandle.writeData(data)
#endif
}
}
2) Add a liveDebugLog(message:)
and put whatever you want to know.
3) Open Terminal.app
and run the command open /tmp/XcodeLiveRendering.log
2)添加aliveDebugLog(message:)
并输入您想知道的任何内容。3)打开Terminal.app
并运行命令open /tmp/XcodeLiveRendering.log
Done!
完毕!
Credits for Morten B?gh
回答by Yuvraj Kale
i have solved that issue by updating the pod "pod update" hope it will work for you
我已经通过更新 pod“pod update”解决了这个问题,希望它对你有用