我一直在试图制作一个CocoaPod,其中包含.xib
整整两天,无济于事。我有一个独立的Xcode项目为我的框架,下面.podspec
:致命错误:无法创建捆绑路径
Pod::Spec.new do |s|
s.name = "OrderStatusTable"
s.version = "1.2.0"
s.platform = :ios
s.ios.deployment_target = '9.0'
s.summary = "Order Status UITableView framework."
s.description = "A UITableView framework with custom view."
s.homepage = "https://github.com/myname/OrderStatusTableView"
s.license = { :type => "MIT", :file => "LICENSE" }
s.author = { "My Name" => "My Email" }
s.platform = :ios, "9.0"
s.source = { :git => "https://github.com/myname/OrderStatusTableView.git", :tag => "1.2.0" }
s.source_files = "OrderStatusTable/**/*.{h,m,swift}"
s.resource_bundles = {
'OrderStatusTable' => [
'Pod/**/*.xib'
]
}
end
在我的样本项目中,我加入pod 'OrderStatusTable', :git => 'https://github.com/myname/OrderStatusTableView.git', :tag => ‘1.2.0’
我Podfile。我.xib
文件包含在示例项目荚内的资源文件夹,但我不断收到此错误:fatal error: Could not create a path to the bundle: file /Users/myname/Desktop/appname/OrderStatusTableDemo/Pods/OrderStatusTable/OrderStatusTable/OrderStatusTable.swift, line 40
这是一个UITableView
框架,我想注册一个定制的UITableViewCell
笔尖与小区复用标识,像这样:
public class OrderStatusTable: UITableView {
public override func awakeFromNib() {
delegate = self
dataSource = self
let podBundle = NSBundle(forClass: self.classForCoder)
if let bundleURL = podBundle.URLForResource("OrderStatusTable", withExtension: "bundle") {
if let bundle = NSBundle(URL: bundleURL) {
let cellNib = UINib(nibName: "OrderStatusTableViewCell", bundle: bundle)
registerNib(cellNib, forCellReuseIdentifier: "OrderStatusTableViewCell")
} else {
assertionFailure("Could not load the bundle")
}
} else {
assertionFailure("Could not create a path to the bundle")
// This keeps getting called
}
}
所以我不知道我是否有错包URLForResource
或什么?这在网上没有很好的记录。有人可以请指教吗?谢谢!