我一直在試圖製作一個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
或什麼?這在網上沒有很好的記錄。有人可以請指教嗎?謝謝!