Close

How to use CocoaPods with Swift project

If you already know how to install and use CocoaPods then continue else please first visit my previous blog “How to install CocoaPods in XCode” (for Objective-C).

 

Using CocoaPods or any Objective C library in Swift is not a big deal. XCode is quite smart and it automatically do this for you. You can also check Apple’s documentation on this Using Swift with Cocoa and Objective-C. Once libraries are added, you only need to use a bridging header between Objective-C and Swift and use the new coding style of Swift for calling those methods. Like [MBProgressHUD show] become MBProgressHUD.show( ) etc. Here I am using the example of MBProgressHUD because it is normally used in most of the projects.

 

Let’s see how it works:

 

1. Create a new XCode project and select the language Swift (no need to to this if you already have Swift project).

 

2. Create a Bridging-Header.h file starting with your project name. like, if my project name is SampleProject, bridging header become: SampleProject-Bridging-Header.h and Put this header at the root directory of your project.

 

If you are not very sure how to do this, the most simplest way is to add a test objective-c file in your project (remove that later). Xcode will prompt an option to configure bridging. When you press Yes, XCode automatically create the bridging file and put inside root of project directory.

 

 

Added Bridging Header:

 

 

3. Setup Pod with your project.

 

4. Add your Pod libraries inside bridging header file as you were normally using in Objective C project.

 

5.  Now you can access MBProgressHUD methods in your swift like:


         MBProgressHUD.showHUDAddedTo(self.view, animated: true)           
         MBProgressHUD.hideAllHUDsForView(self.view, animated:true)

 

 

You can download my SampleProject from git. While reading this if you notice that step5 is missing, then cheers!! you follow this carefully and you understand how it works.

 

Still facing any issue with Pod? Or want to be in touch with us? Contact us at support@triffort.com

 

 

 

Triffort Technologies Pvt Ltd
www.triffort.com

 

 

Posted in iOS, iPhone | iPad, Technology | Tagged CocoaPods, development, iphone, objective-c, pods, swift, xcode

40 Comments

bcgvyW jpbcgaibnyhq, [url=http://lckmclkoguvs.com/]lckmclkoguvs[/url], [link=http://ngmxnjugsuin.com/]ngmxnjugsuin[/link], http://jwkdrfmmgimg.com/

bcgvyW jpbcgaibnyhq, [url=http://lckmclkoguvs.com/]lckmclkoguvs[/url], [link=http://ngmxnjugsuin.com/]ngmxnjugsuin[/link], http://jwkdrfmmgimg.com/

bcgvyW jpbcgaibnyhq, [url=http://lckmclkoguvs.com/]lckmclkoguvs[/url], [link=http://ngmxnjugsuin.com/]ngmxnjugsuin[/link], http://jwkdrfmmgimg.com/

http://canadianonlinepharmacyrgby.com/ - canadian pharmacy meds viagra prices canada drug pharmacy

http://canadaonlinepharmacyhtik.com/ - pharmacy online cheapest generic viagra walmart pharmacy online

http://canadadrugpharmacywhik.com/ - canadian pharmacy king buy viagra soft cialis online pharmacy

http://usconstitutionof1777.com/ - fast cash personal loan american cash loans paycheck loan

http://paydayiloans.com/ - cheap viagra pills canada pharmacy onlineas\kei1.txt,1,N - fast online loans online pharmacy canada

http://canadadrugsonlinergla.com/ - canadian pharmacy review buy viagra without prescription walmart online pharmacy

http://canadadrugsrwdi.com/ - canadian pharmacy meds buy viagra pills modafinil online pharmacy

http://canadianpharmacyonlinesrvh.com/ - online canadian pharmacy buy viagra online ordering drugs from canada

http://drugstoresydik.com/ - canada drugs online buy cheap viagra canadian pharmacies

http://drugstorepharmacyxerh.com/ - canadian online pharmacy 100mg viagra canada drugs direct

http://pharmacystorefvnh.com/ - canadian online pharmacy buy generic viagra cialis online pharmacy

http://vigraformen.com/ - canadian pharmacy viagra buy cheap cialis canadian pharmacy king

http://onlineviagrayvrj.com/ - online prescription for viagra how viagra works viagra online cheap

http://onlinepharmacybvyk.com/ - prescription drugs online pharmacy viagra canadian pharmacy online

http://onlinevigra.com/ - cheap viagra online natural viagra alternatives best place to buy viagra online forum

http://viagrageneric7k.com/ - generic viagra online canada no prescription cialis 10mg buy generic viagra online

http://erectiledysfunctionnfsc.com/ - reputable canadian pharmacy generic viagra cheap canadian pharmacy viagra

http://cheapviagrafasg.com/ - cheap viagra from canada online cialis soft cheap viagra site

http://buyviagrawww.com/ - buy viagra and cialis online viagra in canada buy 100mg viagra online

http://onlinecilkrd.com/ - buy cialis online forum tadalafil dosage cialis online australia paypal

http://onlinesslviaqra.com/ - best online pharmacy for viagra viagra for sale cheap viagra online

http://buycildjea.com/ - buy generic cialis online viagra pharmacy buy cialis pro

http://genericjojos.com/ - best price generic viagra online generic viagra 100mg generic viagra costco

http://genericcilaken.com/ - generic cialis 5mg daily non prescription cialis generic cialis 2018

http://onlinewwwmen.com/ - cheap viagra online order cialis online viagra samples online

http://cheapciljrd.com/ - cheap cialis fast cheap cialis buy cialis generic online cheap

JU5wVV xxertiwryojb, [url=http://hbwvlmqnmect.com/]hbwvlmqnmect[/url], [link=http://fcpkwgmebxfb.com/]fcpkwgmebxfb[/link], http://ugefijiqfyma.com/

http://greengenericjen.com/ - viagra 100mg generic generic tadalafil online generic viagra

http://cheapnowaaaa.com/ - viagra cheap pills effects of viagra where can i get cheap viagra

http://buyjeacialonline.com/ - buying generic cialis online free viagra without prescription buy viagra and cialis online

http://onlineviagriabuy.com/# - ?ยป?cialis online tadalafil reviews buy cialis online in usa

http://genericvigaria.com/# - when will viagra be generic cialis tadalafil when will viagra go generic

http://cheapvirgaraonline.com/# - where to buy viagra online forum generic viagra online where buy viagra online

http://cheapgogenvia.com/ - buy cheap viagra online canadian pharmacy viagra online cheap viagra from india

http://buyviagaraonline.com/# - buy viagra online paypal viagra pills buy cheap generic viagra online

http://buyviagricxr.com/index.html - buy viagra online lowest viagra price buy viagra usa

http://canadabuyeds.com/ - can i buy viagra over the counter cialis without prescription where can i buy viagra with paypal

Leave a reply

Your email address will not be published. Required fields are marked *

Comment

Name

Email

Social Comments
Go top