Set Up the SDK for iOS

To get started with the AWS SDK for iOS, you can set up the SDK and start building a new
project, or you integrate the SDK in an existing project. You can also run the samples to
get a sense of how the SDK works.

To use the AWS SDK for iOS, you will need the following installed on your development
machine:

The samples included with the SDK for iOS are standalone projects that are already set up for you. You can also integrate the SDK for iOS with your own existing project. There are three ways to import the AWS Mobile SDK for iOS into your project:

CocoaPods

Carthage

Dynamic Frameworks

You should use one of these three ways to import the AWS Mobile SDK but not multiple. Importing the SDK in multiple ways loads duplicate copies of the SDK into the project and causes compiler errors.

With your project open in Xcode, select your Target. Under General tab, find Embedded Binaries and then click the + button.

Click the Add Other... button, navigate to the AWS<#ServiceName#>.framework files under Carthage > Build > iOS and select them. Do not check the Destination: Copy items if needed checkbox when prompted.

AWSCore.framework

AWSAutoScaling.framework

AWSCloudWatch.framework

AWSCognito.framework

AWSCognitoIdentityProvider.framework

AWSDynamoDB.framework

AWSEC2.framework

AWSElasticLoadBalancing.framework

AWSIoT.framework

AWSKinesis.framework

AWSLambda.framework

AWSLex.framework

AWSMachineLearning.framework

AWSMobileAnalytics.framework

AWSPinpoint.framework

AWSPolly.framework

AWSS3.framework

AWSSES.framework

AWSSimpleDB.framework

AWSSNS.framework

AWSSQS.framework

Under the Build Phases tab in your Target, click the + button on the top left and then select New Run Script Phase. Then setup the build phase as follows. Make sure this phase is below the Embed Frameworks phase.:

Download the SDK from http://aws.amazon.com/mobile/sdk. The SDK is stored in a compressed
file archive named aws-ios-sdk-#.#.# (where '#.#.#' represents the version number, so for version
2.2.2, the filename is
aws-ios-sdk-2.2.2).

With your project open in Xcode, select your Target. Under General tab, find Embedded Binaries and then click the + button.

Click the Add Other... button, navigate to the AWS<#ServiceName#>.framework files and select them. Check the Destination: Copy items if needed checkbox when prompted.

AWSCore.framework

AWSAutoScaling.framework

AWSCloudWatch.framework

AWSCognito.framework

AWSCognitoIdentityProvider.framework

AWSDynamoDB.framework

AWSEC2.framework

AWSElasticLoadBalancing.framework

AWSIoT.framework

AWSKinesis.framework

AWSLambda.framework

AWSLex.framework

AWSMachineLearning.framework

AWSMobileAnalytics.framework

AWSPinpoint.framework

AWSPolly.framework

AWSS3.framework

AWSSES.framework

AWSSimpleDB.framework

AWSSNS.framework

AWSSQS.framework

Under the Build Phases tab in your Target, click the + button on the top left and then select New Run Script Phase. Then setup the build phase as follows. Make sure this phase is below the Embed Frameworks phase.:

The release of iOS 9 includes changes that might impact how your apps interact with some AWS services. If you compile your apps with Apple’s iOS 9 SDK
(or Xcode 7), there are additional steps you must complete for your app to successfully connect with any AWS service you need to call. For more information,
see Preparing Your Apps for iOS 9.

Most of the service client classes have a singleton method to get a default client. The naming convention is + defaultSERVICENAME (e.g. + defaultDynamoDB in the above code snippet). This singleton method creates a service client with defaultServiceConfiguration, which you set up in step 5, and maintains a strong reference to the client.

AWSS3Transfermanager*transferManager=[AWSS3TransfermanagerdefaultS3TransferManager];AWSS3TransferManagerUploadRequest*uploadRequest=[AWSS3TransferManagerUploadRequestnew];uploadRequest.bucket=yourBucket;uploadRequest.key=yourKey;uploadRequest.body=yourDataURL;uploadRequest.contentLength=[NSNumbernumberWithUnsignedLongLong:fileSize];[[transferManagerupload:uploadRequest]continueWithBlock:^id(AWSTask*task){// Do something with the responsereturnnil;}];

Note

Most of the service client classes have a singleton method to get a default client. The naming convention is +defaultSERVICENAME (e.g. +defaultS3TransferManager in the above code snippet). This singleton method creates a service client with defaultServiceConfiguration, which you set up in step 5, and maintains a strong reference to the client.

Changing log levels during development may make debugging easier. You can change the log level by importing AWSCore.h and calling:

Swift

AWSLogger.defaultLogger().logLevel=.Verbose

The following logging level options are available:

.None

.Error

.Warn

.Info

.Debug (This is the default.)

.Verbose

Objective-C

[AWSLoggerdefaultLogger].logLevel=AWSLogLevelVerbose;

The following logging level options are available:

AWSLogLevelNone

AWSLogLevelError

AWSLogLevelWarn

AWSLogLevelInfo

AWSLogLevelDebug (This is the default.)

AWSLogLevelVerbose

We recommend setting the log level to None before publishing to the Apple App Store.

Get AWS Credentials with Amazon Cognito or AWS Identity and Access Management#

We recommend using Amazon Cognito as your credential provider to access AWS services from your
mobile app. Cognito provides a secure mechanism to access AWS services without having to embed
credentials in your app. To learn more, see Authenticate Users with Amazon Cognito Identity.

Alternatively, you can use AWS Identity and Access
Management (IAM). If you choose IAM, ensure that your role's policy is minimally scoped
so that it can only perform the desired actions for the service being used.

If Xcode was running during this procedure, restart Xcode. To browse the
documentation, go to Help, click Documentation and API Reference, and select AWS SDK for iOS v2.0 Documentation
(where '2.0' is the appropriate version number).