简体   繁体   中英

iOS Swift: Using AWS SDK with xCode6 - error message

Using CocoaPods have added the AWS libraries to my project.

Created a BridgingHeader.h file:

#import "AWSCore.h"
#import "AWSCognito.h"
#import "AWSS3.h"

In application Build Settings > Objective-C Bridging Headers included this BridgingHeader.h file.

Now in my code when i use the credentials initialisation code:

let credentialsProvider = AWSCognitoCredentialsProvider.credentialsWithRegionType(
    AWSRegionType.USEast1,
    accountId: "999999999999",
    identityPoolId: "us-east-1:ac328da6-63f3-4748-9b8f-999999999",
    unauthRoleArn: "arn:aws:iam::69644888888:role/Cognito_s3tutorialUnauth_DefaultRole",
    authRoleArn: "arn:aws:iam::69647777777:role/Cognito_s3tutorialAuth_DefaultRole")

On compilation the error i see is:

credentialsWithRegionType is not available, Use initWithRegionType... instead

I am unable to use initWithRegionType too...because then the error is: AWSCognitoCredentialsProvider does not have a member named initWithRegionType

Surprisingly i can even see the signature and help of this on the right pane of my IDE: AWSCognitoCredentialsProvider.credentialsWithRegionType

What am i missing? Could this be a version mixup?

You might have to use this function as constructor for Swift :

let CognitoRegionType = AWSRegionType.Unknown  // e.g. AWSRegionType.USEast1
let DefaultServiceRegionType = AWSRegionType.Unknown // e.g. AWSRegionType.USEast1
let CognitoIdentityPoolId = "YourCognitoIdentityPoolId"
let S3BucketName = "YourS3BucketName"
let credentialsProvider = AWSCognitoCredentialsProvider(regionType: CognitoRegionType, identityPoolId: CognitoIdentityPoolId)
let configuration = AWSServiceConfiguration(region: DefaultServiceRegionType, credentialsProvider: credentialsProvider)
AWSServiceManager.defaultServiceManager().defaultServiceConfiguration = configuration

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM