Front-End Web & Mobile

Building the AWS SDK for iOS from Source

Version 2 of the AWS Mobile SDK

  • This article and sample apply to Version 1 of the AWS Mobile SDK. If you are building new apps, we recommend you use Version 2. For details, please visit the AWS Mobile SDK page.
  • This content is being maintained for historical reference.

Did you know that the source code for the AWS SDK for iOS is distributed both in the .zip file as well as on GitHub? The code is offered under the Apache License, version 2.0 and available for reuse in your own projects. We welcome submissions for bug fixes and enhancements that will help the entire community of AWS developers.

Since version 1.4.3, the distributed AWS SDK for iOS supports only the armv7 and armv7s architectures and iOS versions 4.3 and higher. If you need support for the armv6 platform or iOS versions prior to 4.3, you will need to rebuild the SDK from source using an older version of Xcode (prior to version 4.5).

To that end, we’ve tried to make it easy for you to build the AWS SDK for iOS from source so you can test out any of your own modifications. There are two main ways you can use the provided source that I’ll cover in this post, but if you have others, please feel free to leave a comment and let us know how you make use of the source in your projects.

Building a framework

The first and most straightforward method of modifying and using the SDK source is to use the provided project file to build a static framework, which you can then include in your other projects. This is the method we use when building the SDK for distribution. It requires the Xcode command line tools, which are available under the Preferences->Downloads tab in Xcode.

Preferences menu

Once you have the command line tools, you can execute this type of build in one of two ways

  • In Xcode

    1. Open the AWSiOSSDK.xcodeproj project and select the Framework scheme. It does not matter what device architecture you select.

      selecting the Framework scheme

    2. Select Product->Build from the Xcode menu.
    3. An updated AWSiOSSDK.framework will appear in the parent of the src directory.
  • From the command line

    1. In your terminal cd to the directory where you downloaded the AWS SDK source. This will be the directory where the AWSiOSSDK.xcodeproj is located.
    2. From this directory run the command Scripts/Framework.sh
    3. An updated AWSiOSSDK.framework will appear in the parent of the src directory.

 

Adding the project to a workspace

You can also choose to add the included AWSiOSSDK.xcodeproj to an Xcode workspace. This would be useful if you are attempting to do multiple iterations against the SDK as the rebuild time will be shorter than the static framework method.

  1. In Xcode, select New->Workspace…, enter your workspace details
  2. Drag the AWSiOSSDK.xcodeproj and another other project files from the Finder into your workspace. Make sure you don’t have these open in another XCode window.

    example workspace

  3. In your project that is including the AWS SDK for iOS, go to the Build Phases tab and click the + under Link Binary With Libraries and select libAWSiOSSDK.a from the selection box.

    link libAWSiOSSDK.a

There are a couple of caveats to this method you should be aware of:

  1. Include paths will not be the same because you are not including Framework headers, your include directives will be in the format:

    #include "SERVICE_NAME/FILE_NAME.h"

    instead of

    #include <AWSiOSSDK/SERVICE_NAME/FILE_NAME.h>
  2. While Xcode will rebuild the library when you make changes to SDK source, you must force a relink of your binary to see any changes.

We encourage you to send us a pull request on GitHub. Please leave a comment below and tell us how you use the SDK and/or what modifications you’ve made.