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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 04:44:07  来源:igfitidea点击:

Interface Builder - Failed to load designables from path (null)

iosinterface-builderxcode6custom-controlsibdesignable

提问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,并通过执行以下步骤使错误神奇地消失,最终使我的项目处于执行这些步骤之前的确切状态(即对任何内容进行净零更改):

  1. Add 'use_frameworks!' (without the apostrophes, of course) to your podfile
  2. Open up a terminal window
  3. cd to your project's root dir
  4. Run 'pod install' from the command line
  5. Remove the 'use_frameworks!' from your podfile
  6. Run 'pod install' again
  7. Try building again and see if that fixes the error; it did for me
  1. 添加“use_frameworks!” (当然没有撇号)到你的 podfile
  2. 打开终端窗口
  3. cd 到你项目的根目录
  4. 从命令行运行“pod install”
  5. 删除“use_frameworks!” 从你的 podfile
  6. 再次运行“pod install”
  7. 再次尝试构建,看看是否修复了错误;它对我有用

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,但这似乎并没有解决它。要解决它,我必须转到“窗口”>“项目”,选择框架项目(不是使用框架的项目,而是框架项目本身),然后删除派生数据。所以,完整的步骤:

  1. Product menu > Clean
  2. Hold down Option > Product menu > Clean Build Folder... > Clean
  3. Window menu > Projects > Choose my Framework project > Delete Derived Data
  4. Window menu > Projects > Choose my main project > Delete Derived Data
  5. Quit Xcode
  6. Restart Xcode
  1. 产品菜单 > 清洁
  2. 按住 Option > Product 菜单 > Clean Build Folder... > Clean
  3. 窗口菜单 > 项目 > 选择我的框架项目 > 删除派生数据
  4. 窗口菜单 > 项目 > 选择我的主项目 > 删除派生数据
  5. 退出 Xcode
  6. 重启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 IBDesignableviews. Apparently, it's an Xcode bug. Steps in this answerhelped me to resolve the problem. In short:

我在带有自定义IBDesignable视图的非 CocoaPods 项目上遇到了同样的问题。显然,这是一个 Xcode 错误。这个答案中的步骤帮助我解决了这个问题。简而言之:

  1. Quit Xcode.
  2. Kill all processes named Interface Builder Cocoa Touch Toolon your machine.
  3. Start Xcode again.
  1. 退出 Xcode。
  2. 杀死Interface Builder Cocoa Touch Tool在您的机器上命名的所有进程。
  3. 再次启动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

查找更多:使用 IB_DESIGNABLE 从 pod 依赖项实时渲染自定义组件

回答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.appand run the command open /tmp/XcodeLiveRendering.log

2)添加aliveDebugLog(message:)并输入您想知道的任何内容。3)打开Terminal.app并运行命令open /tmp/XcodeLiveRendering.log

Done!

完毕!

Credits for Morten B?gh

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”解决了这个问题,希望它对你有用