我是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 */
我在构建设置中指向该文件,以告诉编译器它在哪里。
然后,我尝试使用以下代码在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字符串等。我只是不想张贴它们)
一切正常,除了最后一行:
AWSServiceManager.defaultServiceManager().setDefaultServiceConfiguration(defaultServiceConfiguration)
错误说:
"Value of type 'AWSServiceManager' has no member 'setDefaultServiceConfiguration'"
为什么除了这条线外一切都正常?怎么了?
最佳答案
AWSServiceManager
没有用于defaultServiceConfiguration
的设置器。
相反,您必须使用
AWSServiceManager.defaultServiceManager().defaultServiceConfiguration = defaultServiceConfiguration
可以的