Я хочу использовать Swift proj. как локальный блок в другом проекте Swift.CocoaPods: используйте местный пакет, написанный быстрым
Мой стручок только один быстр файл с расширением UIImageView:
//
// 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:
# Podfile
platform :ios, '8.0'
pod 'WSImageLoader', :path=>'~/untitled folder/WSImageLoader'
use_frameworks!
Мои ViewController
//
// 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 установить и скомпилировать proj. работает, но как использовать loadWithUrl от pod?
pod --version
0.36.0
Podspec
# 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
Вам это удалось? У меня такая же проблема. – sarunw