【发布时间】:2015-03-18 20:39:32
【问题描述】:
我想使用 Swift 项目。作为其他 Swift 项目中的本地 pod。
我的 pod 只是一个带有 UIImageView 扩展名的 swift 文件:
//
// UIImageView+loader.swift
//
import UIKit
extension UIImageView {
func loadWithUrlString(urlString: String) {
var url = NSURL(string: urlString)
if url != nil {
self.loadWithUrl(url!)
}
}
func loadWithUrl(url : NSURL) {
let session = NSURLSession.sharedSession()
let urlRequest = NSURLRequest(URL: url)
session.dataTaskWithRequest(urlRequest, completionHandler: { (data:NSData!, response:NSURLResponse!, error: NSError!) -> Void in
println("response")
})
}
}
我的播客文件:
# Podfile
platform :ios, '8.0'
pod 'WSImageLoader', :path=>'~/untitled folder/WSImageLoader'
use_frameworks!
我的视图控制器
//
// ViewController.swift
//
import UIKit
import WSImageLoader
class ViewController: UIViewController {
@IBOutlet weak var imageView: UIImageView!
override func viewDidLoad() {
super.viewDidLoad()
// does not work here ('UIImageView' does not have a member named 'loadWithUrl')
self.imageView.loadWithUrl("http://www.axialis.com/tutorials/iw/down.ico")
}
}
Pod 安装和编译项目。有效,但如何使用 loadWithUrl 来自 pod?
pod --version
0.36.0
Pod 规格
# WSImageLoader.podspec
Pod::Spec.new do |s|
s.name = "WSImageLoader"
s.version = "0.0.1"
s.summary = "A short description of WSImageLoader."
s.description = ""
s.homepage = "http://EXAMPLE/WSImageLoader"
s.license = "MIT (example)"
s.author = { "" => "" }
s.platform = :ios, "8.0"
s.source = { :git => "http://EXAMPLE/WSImageLoader.git", :tag => "0.0.1" }
s.source_files = "WSImageLoader/Classes/**/*.{swift}"
s.exclude_files = "Classes/Exclude"
s.public_header_files = "Classes/**/*.swift"
end
【问题讨论】:
-
你能解决这个问题吗?我遇到了同样的问题。