我的项目只有Obj。通过Cocoapods,我尝试安装一个Obj-C库,利用IBDesignable和IBInspectable。如果我将该项目添加到我的库中并运行'pod‘,则在构建/运行时会出现两个错误:
error: IB Designables: Failed to update auto layout status: Failed to load designables from path (null)
error: IB Designables: Failed to render instance of PKCircleProgressView: Failed to load designables from path (null)好的,很明显,要利用IBDesignable/IBInspectable,您的代码需要在一个框架中,而不是静态库中。看来我所要做的就是把这个添加到我的Podfile中:
use_frameworks!当我这样做时,我能够看到Interface中的一切,但是当我构建/运行时,它找不到AFNetworking.h。我不认为这个错误是AFNetworking特有的,它只是我的Podfile中的第一个荚。
如果我使用Swift,答案似乎是我需要将Podfile中的所有库添加到我的Swift/Obj桥接头中。
即使我没有使用Swift,我还需要创建一个桥接头吗?
这里是我的Podfile (没有DownloadButton荚,也没有use_frameworks!):
platform :ios, '8.0'
pod 'AFNetworking'
pod 'FMDB'
pod 'HKCircularProgressView'
#pod 'Taplytics'
pod 'PAPreferences'
pod 'HTMLLabel'
pod 'IDMPhotoBrowser'
pod 'MBProgressHUD'
link_with 'Langham', 'Leela', 'Las Alcobas', 'Siam', 'AKA BH', 'Ritz Montreal', 'Fullerton', 'Fullerton Bay'
# Fix broken copy-resources phase per https://github.com/CocoaPods/CocoaPods/issues/1546
post_install do |installer|
installer.pods_project.targets.each do |target|
scriptBaseName = "\"Pods/Target Support Files/#{target.name}/#{target.name}-resources\""
sh = <<EOT
if [ -f #{scriptBaseName}.sh ]; then
if [ ! -f #{scriptBaseName}.sh.bak ]; then
cp #{scriptBaseName}.sh #{scriptBaseName}.sh.bak;
fi;
sed '/WRAPPER_EXTENSION/,/fi\\n/d' #{scriptBaseName}.sh > #{scriptBaseName}.sh.temp;
sed '/*.xcassets)/,/;;/d' #{scriptBaseName}.sh.temp > #{scriptBaseName}.sh;
rm #{scriptBaseName}.sh.temp;
fi;
EOT
`#{sh}`
end
end发布于 2015-08-08 23:40:09
校正
IBInspectable和IB_DESIGNABLE与Swift无关。它们可以用于Swift或Objective。这是一个iOS版本的问题,偶尔也会在IB中设置Module。
现实生活示例
iOS 7不支持IBInspectable,因此对两个控件都使用.7类。如果您的项目以iOS 8+为目标,则应使用TGPDiscreteSlider & TGPCamelLabels
为iOS 7创建一个基类(先前的IBInspectable)
@interface TGPCamelLabels7 : UIControl...
@property (nonatomic, assign) CGFloat ticksDistance;
@property (nonatomic, assign) NSUInteger value;
// ...为iOS 8创建一个子类
@interface TGPCamelLabels : TGPCamelLabels7
@property (nonatomic) IBInspectable CGFloat ticksDistance;
@property (nonatomic) IBInspectable NSUInteger value;
// ...以这种方式,您的Pod可以在任何一种模式下使用。它已经在这个TGPControls球囊上得到了详细的解决。
下载该项目,您将发现两个示例Xcode项目,一个用于Swift,1个用于
https://stackoverflow.com/questions/31883968
复制相似问题