Set up and run the Office 365 iOS SDK Samples

One of the best things about the Office 365 REST APIs is that it comes with an iOS SDK. That means you don't have to get down to the level of constructing HTTP calls - it's all abstracted away for you in the SDK.

Let's see how the SDK works by downloading and running a sample.

1. Go to the Office 365 SDK for iOS GitHub repository and clone it. You can either do that using the command line, or via the Mac desktop client.

Clone by clicking "Clone in Desktop" on the lower-right of this screenshot.

Clone by clicking "Clone in Desktop" on the lower-right of this screenshot.

2. After you've cloned the repository, cd into it using the terminal. Then, cd into the Samples folder. You'll notice there are three Samples: 

This is because there are currently three services that are under the Office 365 umbrella - OneDrive for Business (also known as SharePoint), Exchange, and Discovery (which is more of a tool to help you find the right endpoint for the service, than a service itself). In this tutorial, let's focus on the simple-drive-app sample. 

3. cd into simple-drive-app sample. Then, run the following command:

pod install

Please make sure that you have cocoapods installed already. This is a must-have for any Mac developer, so head on over to their website and learn how to set it up if you aren't already familiar with using it.

This is what you'll see if after cocoapods has successfully downloaded the dependencies.

4. Open the workspace:

XCode should launch and you'll see this:

5. Run the app on a simulator or device. In this case, I'm running it on a simulator. You'll see that it asks you for these things: Authority Url, Redirect Url and Client Id.

6. In order to get these, we must first register an app in Azure AD.

This tutorial assumes that you already know what Azure AD is, and that you have an Azure account as well as an Office 365 Developer Tenant. Here's a step-by-step walkthrough on how to set up an Office 365 Developer Tenant.

Go to, and click on Portal at the top. Enter your login for Azure, and select your Active Directory that you want this app to be registered to. Let's say we want to test it on my Office 365 tenant, so in this case, I select that tenant. You'll be able to select your own tenant here based on what you created previously.

Once you've select your Active Directory, click on "Applications" as shown below:

At the bottom, press "Add"

Select "Add an application my organization is developing" and on the next page, enter any name for your application. In this case, I'm using "iOS-Drive-Sample". Select "Native Client Application" since it's going to run on a mobile device.

On the next page, type anything you want into the Redirect URI box. I chose "" as my redirect URI.

Press OK. Go to "Configure" and you'll see the following:

First we want to press the green "Add application" button below and select "Office 365 SharePoint Online"

Then after we press the OK button, we'll want to just select all the permissions that we need for this sample app. Select "Read users' files" and "Edit or delete users' files" for now.

Press "Save" so the changes are saved.

7. Go back to the app running in the simulator, and under "Authority URL", paste the following: Replace YOURTENANT with the tenant address of your developer tenant. E.g. if your developer tenant is, your Authority URL is

For redirect URL and client ID, paste the ones that are shown on the Azure AD Application dashboard.

Press Save, and then press "Files" on the bottom tab bar after you're done filling up these, and you'll see our good 'ol login screen.

Sign in with your developer tenant account. E.g. ""

Screen Shot 2015-01-05 at 2.44.23 PM.png

8. Something's gone wrong - you'll see a very annoying loading indicator, and your files don't show up. Uh-oh, let's back up a bit and try to fix what's going on.

If you go back to Xcode and look at the Output, you'll see this:

Strange, why is it making a GET request to "" when that's not your OneDrive for Business (i.e. SharePoint) endpoint?

Fortunately, it's just changing a single string. Do a search in your workspace for "teeudev1" and you'll quickly realize that BaseController.m has that URL hard-coded in it. 

Replace teeudev1 with your tenant address. So if your developer tenant is "", you'll want to replace that highlighted text in the image above with ""

9. Run the app again. Select "Files" in the bottom tab bar and you should see all your files displayed!

Note: If it didn't work, press "Clear Credentials" under Settings and try logging in again.

I hope this helps you get the sample project set up and configured. 

You can press the "+" on the top right to create and upload a new text file.

Screen Shot 2015-01-05 at 2.59.02 PM.png

The files that are showing are the same files that are in your root folder in OneDrive for Business. You can access OneDrive for Business by going to the Office portal page and clicking on "OneDrive" at the top.

I hope this was helpful - if you have any questions, leave them in the Comments below and I'll try to answer them.