【发布时间】:2016-06-30 18:06:10
【问题描述】:
迁移到 Cocoapods 1.0 后,我使用自定义 IBDesignable 的 XIB 或 Storyboard 都无法在动态框架项目上正确呈现。它失败并出现如下错误:
file:///Users/xxxxx/workspace/FooFramework/FooFramework/View.xib: error: IB Designables: Failed to update auto layout status: dlopen(FooFramework.framework, 1): Library not loaded: @rpath/Alamofire.framework/Alamofire
Referenced from: FooFramework.framework
Reason: image not found
file:///Users/xxxxx/workspace/FooFramework/FooFramework/View.xib: error: IB Designables: Failed to render instance of CustomView: dlopen(FooFramework.framework, 1): Library not loaded: @rpath/Alamofire.framework/Alamofire
Referenced from: FooFramework.framework
Reason: image not found
重现步骤:
- 创建一个新的 iOS 框架项目。
- 创建任何依赖项并将其添加到
Podfile文件。例如:
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
use_frameworks!
target 'FooFramework' do
pod 'Alamofire'
end
- 执行
pod install并打开.xcworkspace文件。 - 创建自定义
IBDesignableUIView子类。例如:
import UIKit
@IBDesignable class CustomView: UIView {
override init(frame: CGRect) {
super.init(frame: frame)
layer.cornerRadius = 10
}
required init?(coder aDecoder: NSCoder)
{
super.init(coder: aDecoder)
layer.cornerRadius = 10
}
}
- 创建新的 XIB 或 Storyboard 并添加自定义视图。
此时 XCode 将重新编译代码并且将无法呈现自定义视图。给出上面提到的错误。
但是,工程编译正确,创建的XIB在执行时成功显示在模拟器中。它只会在 Interface Builder 的渲染时间上失败。
使用 Cocoapods 0.38 或可执行项目的相同过程按预期工作,没有获得错误,并且自定义视图正确呈现。
我是否缺少Podfile 中的任何配置参数?它是 Cocoapods 的错误吗?有什么解决办法吗?
更新:
尝试使用不同的Runpath Search Paths 和Installation Directory,如here 和here 所述,但没有成功。
找到了使用 Cocoapods 0.39 的解决方法,仍然可以正常工作:
pod _0.39.0_ install
【问题讨论】:
标签: ios xcode interface-builder cocoapods