ios IB Designables:无法更新自动布局状态:无法从路径加载 designables(空)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/28204108/
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:34:50  来源:igfitidea点击:

IB Designables: Failed to update auto layout status: Failed to load designables from path (null)

iosxcode

提问by Oren

I'm seeing this error for a XIB. But everything else compiles and there doesn't seem to be any harm done by this error. Is this something I need to worry about? What's the problem here and how would I go about fixing this?

我看到了 XIB 的这个错误。但是其他所有内容都可以编译,并且此错误似乎没有造成任何伤害。这是我需要担心的事情吗?这里有什么问题,我将如何解决这个问题?

enter image description here

在此处输入图片说明

UPDATE: I've updated cocoapods to the latest version (0.36.3) and while that fixed the problem for a few compiles, the error has returned and I'm now seeing an additional error:

更新:我已经将 cocoapods 更新到最新版本 (0.36.3),虽然这解决了一些编译的问题,但错误已经返回,我现在看到一个额外的错误:

enter image description here

在此处输入图片说明

回答by Andrei Konstantinov

It is a known issue in CocoaPods. It has been fixed in version 0.36.1. Just update your CocoaPods and then add specific line of code to your pod file: use_frameworks!after platform :ios, '7.0'

这是 CocoaPods 中的一个已知问题。它已在版本0.36.1 中修复。只需更新您的 CocoaPods,然后将特定的代码行添加到您的 pod 文件中: use_frameworks!平台:ios,'7.0'

So your file will look like this:

所以你的文件看起来像这样:

platform :ios, '7.0'

use_frameworks!

/// here will be dependencies etc. ///

updated:

更新:

Full list of steps to get rid of the problem once and for all:

一劳永逸地解决问题的完整步骤列表:

  • Close project;
  • Open Terminal App;
  • Update CocoaPods itself to ver. 0.36.1 or later;
  • Navigate to your project folder in Terminal;
  • Type: pod update;
  • Open your project in xCode;
  • Clean project;
  • Build project again.
  • 关闭项目;
  • 打开终端应用程序;
  • 将 CocoaPods 本身更新到 ver. 0.36.1 或更高版本;
  • 在终端中导航到您的项目文件夹;
  • 类型:pod update;
  • 在 xCode 中打开您的项目;
  • 清洁项目;
  • 再次构建项目。

回答by Bart?omiej Semańczyk

After doing some research and digging, I can confirm, that there is no way to solve this problem.

经过一些研究和挖掘,我可以确认,没有办法解决这个问题。

This is an Xcode's bug.

这是 Xcode 的错误。

That's all. We must wait for update.

就这样。我们必须等待更新。

Just restartthe Xcode for now.

现在只需重新启动Xcode。

回答by Wojtek Dmyszewicz

This worked for me:

这对我有用:

  1. remove derived data (preferences > locations)
  2. restart Xcode
  3. clean project (product > clean)
  1. 删除派生数据(首选项 > 位置)
  2. 重启Xcode
  3. 清洁项目(产品 > 清洁)

回答by Yaro

2016is the year, xCode 7.3.1: I got this error. (Using cocoa pods 1.0 but it does not matter)

2016年,xCode 7.3.1:我收到了这个错误。(使用可可豆荚 1.0 但没关系)

CAUSE:a special UILabel subclass was used in IB. ring a bell?

原因:在 IB 中使用了一个特殊的 UILabel 子类。按门铃?

ELEGANT SOLUTION:

优雅的解决方案:

1: Subclass TTTAttributedLabel or FXLabel or whatever u have. Use that in IB.

1:子类 TTTAttributedLabel 或 FXLabel 或任何你有。在IB中使用它。

2: Add these lines in the subclassed .h file:

2:在子类的 .h 文件中添加这些行:

#ifndef IB_DESIGNABLE
#define IB_DESIGNABLE
#endif

@class LabelFromPod;


IB_DESIGNABLE @interface YourLabel : LabelFromPod {
 ...
}

3: then I think you have to clear project, exit xCode, rebuild (usual xCode panic protocol) and the problem will go away.

3:那么我认为您必须清除项目,退出xCode,重建(通常的xCode恐慌协议),问题就会消失。

UPDATE 2017xCode 8.2.1: It all getting worse :( The blank VC problem: The IB does not even load the UI elements for a view controllers that have these IB_DESIGNABLEs. I'm clueless :)

更新 2017xCode 8.2.1:一切都变得更糟了 :( 空白 VC 问题:IB 甚至没有为具有这些 IB_DESIGNABLEs 的视图控制器加载 UI 元素。我一无所知 :)

回答by redcomethk

I faced the same problem using TTTAttributedLabel and followed Andrey's answer to try to fix it. The build was successful but after that it seems that the bundle files of other pod modules (TSMessage, SVProgressHUD in my case) cannot be loaded. This is also stated in the Cocoapods blog postand I do not want to move the bundle resources to the mainBundle (and I have not verified if this works.)

我使用 TTTAttributedLabel 遇到了同样的问题,并按照 Andrey 的回答尝试修复它。构建成功,但之后似乎无法加载其他 pod 模块(在我的情况下为 TSMessage、SVProgressHUD)的包文件。这也在Cocoapods 博客文章中说明,我不想将捆绑资源移动到 mainBundle(我还没有验证这是否有效。)

Therefore I choose to remove TTTAttributedLabel from the Podfile and just include the source directly to get rid of that error. This works for me and I hope it is also another answer to this problem.

因此,我选择从 Podfile 中删除 TTTAttributedLabel 并直接包含源以消除该错误。这对我有用,我希望它也是这个问题的另一个答案。

回答by Han Daniel

May be late, but adding these codes for initialization worked for me when I got this problem

可能晚了,但是当我遇到这个问题时,添加这些初始化代码对我有用

required override init(frame: CGRect) {
    super.init(frame: frame)
}

required init?(coder aDecoder: NSCoder) {
    super.init(coder: aDecoder)
}

回答by Durai Amuthan.H

I had the same issue as I was using custom view from POD on storyboard.

我在故事板上使用 POD 的自定义视图时遇到了同样的问题。

Doing the following things fixed the issue for me

做以下事情为我解决了这个问题

  • Add the following line (To turn the POD in dynamic framework) on pod use_frameworks!
  • Do pod update
  • Restart the Xcode
  • 在 pod 上添加以下行(To turn the POD in dynamic framework) use_frameworks!
  • pod update
  • 重新启动Xcode

回答by Haroldo Gondim

In Podfileadd this script at the end and performed pod installagain.

在最后Podfile添加此脚本并pod install再次执行。

post_install do |installer|
    installer.pods_project.build_configurations.each do |config|
        config.build_settings.delete('CODE_SIGNING_ALLOWED')
        config.build_settings.delete('CODE_SIGNING_REQUIRED')
    end
end

回答by Denis Kutlubaev

I had a similar bug, when I was using Cocoapodsand was not able to use_frameworks!. I ended up by forking a framework, that uses IBDesignableand IBInspectableand removing these keywords. All customization is done programmatically:

我有一个类似的错误,当我使用Cocoapods并且无法use_frameworks!. 我最终通过派生一个框架,使用IBDesignableIBInspectable和移除这些关键字。所有自定义都以编程方式完成:

class CardFloatingLabelTextField: SkyFloatingLabelTextField {

    required init?(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)

        self.errorMessage = nil
        self.titleFont = UIFont.systemFont(ofSize: 11)
        self.titleFormatter = { (text: String) in return text }
        self.titleColor = UIColor.channelsColorGrayFootnoteAndCaptions()
        self.selectedTitleColor = UIColor.channelsColorGrayFootnoteAndCaptions()
        self.lineColor = UIColor.channelsColorGrayContentAndLines()
        self.selectedLineColor = UIColor.channelsColorDarkBlue()
        self.lineHeight = 1
        self.selectedLineHeight = 1

    }

}

It works and doesn't create bugs in Interface builder anymore. However, it's a pity, that I had to do this workaround.

它可以工作并且不再在 Interface builder 中产生错误。但是,很遗憾,我不得不执行此解决方法。

回答by Sunil Targe

Remove what you've in the Podfile and just include the source directly to fix this issue.

删除您在 Podfile 中的内容,只需直接包含源代码即可解决此问题。

It works for me!

这个对我有用!