iOS Swift:将 AWS SDK 与 xCode6 一起使用 - 错误消息

iOS Swift: Using AWS SDK with xCode6 - error message

使用 CocoaPods 已将 AWS 库添加到我的项目中。

创建了一个 BridgingHeader.h 文件:

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

在应用程序构建设置 > Objective-C 桥接 Headers 中包含此 BridgingHeader.h 文件。

当我使用凭据初始化代码时,现在在我的代码中:

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")

编译时我看到的错误是:

credentialsWithRegionType is not available, Use initWithRegionType... instead

我也无法使用 initWithRegionType...因为错误是:AWSCognitoCredentialsProvider 没有名为 initWithRegionType

的成员

令人惊讶的是,我什至可以在 IDE 的右窗格中看到它的签名和帮助:AWSCognitoCredentialsProvider.credentialsWithRegionType

我错过了什么?这可能是版本混淆吗?

您可能必须将此函数用作 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