桥接式 AWS 开发工具包上的 XCode 错误



我对iOS很陌生,对AWS来说是100%新手。我正在构建一个需要上传文件的应用程序。我通过 CocoaPods 下载了 Amazon SDK,并使用桥接标头在 Swift 中使用它。

这是我的标题:

#ifndef ObjC_Bridging_Header_h
#define ObjC_Bridging_Header_h
#import "AWSCore.h"
#import "AWSS3.h"
#import "AWSDynamoDB.h"
#import "AWSSQS.h"
#import "AWSSNS.h"
#import "AWSCognito.h"
#endif /* ObjC_Bridging_Header_h */

我在构建设置中指向该文件,告诉编译器它在哪里。

然后,我尝试使用以下代码在我的应用程序委托中配置 SDK.swift:

var window: UIWindow?
let cognitoAccountId = "I'm not going to post this"
let cognitoIdentityPoolId = "I'm not going to post this"
let cognitoUnauthRoleArn = "I'm not going to post this"
let cognitoAuthRoleArn = "I'm not going to post this"
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
    let credentialsProvider = AWSCognitoCredentialsProvider.credentialsWithRegionType(
        AWSRegionType.USEast1,
        accountId: cognitoAccountId,
        identityPoolId: cognitoIdentityPoolId,
        unauthRoleArn: cognitoUnauthRoleArn,
        authRoleArn: cognitoAuthRoleArn)
    let defaultServiceConfiguration = AWSServiceConfiguration(
        region: AWSRegionType.USEast1,
        credentialsProvider: credentialsProvider)
    AWSServiceManager.defaultServiceManager().setDefaultServiceConfiguration(defaultServiceConfiguration)

    return true
}

(是的,我输入了所有的 ID 字符串等。我只是不想发布它们)

除了最后一行之外,一切正常: AWSServiceManager.defaultServiceManager().setDefaultServiceConfiguration(defaultServiceConfiguration)

它错误地说: "Value of type 'AWSServiceManager' has no member 'setDefaultServiceConfiguration'"

为什么除了这条线之外一切都在工作?怎么了?

AWSServiceManager没有defaultServiceConfiguration的二传手。

相反,您必须使用

AWSServiceManager.defaultServiceManager().defaultServiceConfiguration = defaultServiceConfiguration

这会起作用。

相关内容

最新更新