iOS Swift:将AWS SDK与xCode6一起使用 – 错误消息
使用CocoaPods已将AWS库添加到我的项目中。
创建了一个BridgingHeader.h文件:
#import "AWSCore.h" #import "AWSCognito.h" #import "AWSS3.h"
在应用程序构建设置> Objective-C桥接标题中包含此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不可用,请改用initWithRegionType ….
我也无法使用initWithRegionType …因为那时错误是: AWSCognitoCredentialsProvider没有名为initWithRegionType的成员
令人惊讶的是,我甚至可以在IDE的右侧窗格中看到此签名和帮助:AWSCognitoCredentialsProvider.credentialsWithRegionType
我错过了什么? 这可能是版本混淆吗?
您可能必须使用此函数作为Swift
构造函数:
let CognitoRegionType = AWSRegionType.Unknown // eg AWSRegionType.USEast1 let DefaultServiceRegionType = AWSRegionType.Unknown // eg 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