使用 CocoaPods 已将 AWS 库添加到我的项目中。
创建了一个 BridgingHeader.h 文件:
#import "AWSCore.h"
#import "AWSCognito.h"
#import "AWSS3.h"
在应用程序 Build Settings > Objective-C Bridging 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 的右 Pane 中看到它的签名和帮助: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
关于iOS swift : Using AWS SDK with xCode6 - error message,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30522168/