How to add Microsoft's Azure Services to your Swift apps

Let’s see how to integrate an Azure service into your Swift application in Xcode. What I’m about to show you will work with any of Azure’s iOS libraries since they are all written in Objective-C. 

Just head over to Microsoft’s GitHub repo’s and download the service library you need.

In this tutorial, we’ll install Azure Storage Client Library for blob storage. 

Now, there are a couple of ways to install these libraries. You can use CocoaPods, which if you’re using the same point release of Xcode that the library was created with you should be alright, otherwise, you’re sure to be in for an untold quantity of build errors before you’re up and running. Alternatively, you could install the service as a framework provided it was compiled correctly for your current Xcode version. Or, you can do it the fool-proof way, and just include the Objective-C files into your application and add a bridging header. 

(Dear Apple, please see Nuget Package Manager…)

This is my preferred approach because it's timeless. Doesn’t matter which version of Swift you are using or what version of Xcode you’re using. It just works.

So, assuming you’ve got an existing Xcode project and the Azure service you wish to install downloaded to your computer. We can get started.

In the downloaded folder, look for the Objective-C source code. In the case of Azure Storage Client Library, its a folder named after the service. So, find something like this:


Next, create a new Group in your Xcode project and name it whatever you like. I just named mine “Azure Storage”. Once you have the folder created, go ahead and drag all of the Objective-C files from the folder you downloaded to your new Xcode project folder. Select copy if needed and then “Finish”.

Xcode will then ask you if you want to create a bridging header for these Objective-C files, select “Create Bridging Header”, we’ll need this bridging header to expose Azure to our Swift code.


By default, Xcode will place that bridging header in with off of Azure’s Objective-C files, I personally move this file into my own project hierarchy since I might reuse this file to incorporate other Objective-C libraries.

If we choose to move it, we’ll need to inform Xcode where we moved it to. We can update our bridging header path by editing the location stored under Objective-C Bridging Header in our Build Settings

Since I moved my bridging header into the main project hierarchy, I had to update my path to “AzureStorageExample/AzureStorageExample-Bridging-Header.h”


Once we have that updated, Xcode will, once again, be able to expose Azure’s Objective C code to our Swift code. Of course, this wouldn’t be a day in the life of an Xcode user if there wasn’t a follow-up error.


Looks like Azure has a dependency on `libxml/xmlwriter.h`, which is pretty simple to resolve. We’ll just have to tell Xcode where the file is. 

We’ll go back into our build settings and select “All” and then “Levels” from our build settings and then search for “Search Paths”. Under header search paths, we’ll add a search path of “${SDKROOT}/usr/include/libxml2”.

If we rebuild we’ll get a gang of errors. We’ve got one last step here.

Go to build phases > link library with binaries and add libxml2.tbd to your project.


Rebuilding now should result in a successful deployment.


If you run into any issues you can download the example project from GitHub here. You can also feel free to comment below and I'll do my best to help.