iOS Swift: Using AWS SDK with xCode6 - error messa

2019-06-01 03:41发布

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?

1条回答
对你真心纯属浪费
2楼-- · 2019-06-01 04:06

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
查看更多
登录 后发表回答