Tips: Importing Objective C Library into Swift


Coding could be done a lot easier if you know how to import libraries that have been created by other developers. Some of the most common ways in iOS Development is to either use Cocoapods (I’ve created a tutorial for that) or using GitHubs. We should definitely be grateful that there are developers out there that allow us to use their libraries. A round of applause for them.

For this project, we will be using ProgressHUD from GitHub which is written in Objective C. You may access the site and download the zip file.

Unzip the zip file and open the ProgressHUD folder and another ProgressHUD folder and drag the files to XCode.

I’ve created a folder where I could copy the files into the folder to keep my files organized. Make sure to click on Copy items if needed.

This will prompt another alert in which you should click Create Bridging Header.

Now you will notice that an additional file is created, that is the bridging file. Then we need to import the library in the newly created bridging file before we could use it.

Then we’ll go into the design and coding part. We will be using two button here to display the success and error. Make sure you create IBAction for both of the buttons.

This is a very straight forward code here which explain when you click on the success error, it will show a pop up with a description of success and it works the same with error as well. You can change the description to anything you prefer.

@IBAction func successPressed(_ sender: Any) {
@IBAction func errorPressed(_ sender: Any) {


The code will be uploaded to GitHub

  • Article By :
    Founder of DaddyCoding. Studied Computer Science, Information System and Information Technology at BYU-Hawaii. Currently spending most of my time researching and learning on helping to expose making iOS apps.

Random Posts

Leave a Reply

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