我对 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'"
为什么除了这条线外一切正常?怎么了?