Monday, 15 April 2013

ios - CocoaPods: use local pod written in swift -


I want to use a swift project as a local pod in other swift projections.

My pod is a fast file with UIImageView extensions:

  // // UIImageView + loader.swift // import UIKit extensions UIImageView {function loadWithUrlString (urlString: String) {var url = NSURL (string: urlString) if url = zero {self.loadWithUrl}} function loadWithUrl (url: NSURL)! (URL!) {The session = NSURLSession.sharedSession () to URLRequest = NSURLRequest (URL: URL) session.dataTaskWithRequest (URLRequest, completionHandler: {(data: NSData!, Responded: NSURLResponse!, Error: NSError) - & gt; zero ( "response") in println!})}}  

I Podfile:

  # Podfile forum: ios, '8.0' pods 'WSImageLoader' ,: Path = & gt; '~ / Untitled folder / WSImageLoader' use_frameworks!  

My ViewController

  // // ViewController.swift // import UIKit import WSImageLoader class ViewController: UIViewController {@IBOutlet weak bridesmaid imageView: UIImageView! viewDidLoad () {super.viewDidLoad () does not function overrides // work here self.imageView.loadWithUrl ( "http://www.axialis.com/tutorials/ ( 'UIImageView' does not designate a member 'loadWithUrl') Iw / down.ico ")}}  

PD installs and compiles, but how to use loadWithUrl from the pod?

  pod - Description 0.36.0  

podspack

  # WSImageLoader.podspec Pod :: Spec.new do | S | S.name = "WSImageLoader" s.version = "0.0.1" s.summary = "Brief description of WSImageLoader." S.description = "" s.homepage = "http: // EXAMPLE / WSImageLoader" s.license = "MIT (example)" s.author = {"" = & gt; ""} S.platform =: iOS, "8.0" s.source = {: git = & gt; "Http: //EXAMPLE/WSImageLoader.git" ,: tag = & gt; "0.0.1"} s.source_files = "WSImageLoader / class / ** / *. {Sharp}" s.exclude_files = "square / Exclude" s.public_header_files = "class / ** / *. Sharp" end < / Code> 

You have swiftly expanded Swift files are not currently supported in Swift, as Here's also discussed:

Then use that extension file to write in Swift (UIImageView + loader.swift) just type in the Objective-C and the process below uses the U function. Switch to.

You will have to import header files from local fonds. This tutorial has helped me to import other pod files successfully.

Hope this also help u


No comments:

Post a Comment