XCode 桥接 AWS SDK 错误

XCode Errors on bridged AWS SDK

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

这是我的 header:

#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 */

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

然后我尝试使用以下代码在我的 AppDelegate.swift 中配置 SDK:

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 字符串等。我只是不想 post 它们)

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

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

为什么除了这条线以外的一切都正常?怎么了?

AWSServiceManager 没有 setter defaultServiceConfiguration

你必须使用

AWSServiceManager.defaultServiceManager().defaultServiceConfiguration = defaultServiceConfiguration

这行得通。