ios - 桥接 AWS SDK 上的 XCode 错误

标签 ios xcode swift amazon-web-services bridging-header

我对 iOS 还很陌生,对 AWS 也是 100% 的新手。我正在构建一个需要上传文件的应用程序。我通过 CocoaPods 下载了 Amazon SDK,并使用桥接 header 在 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 */

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

然后我尝试使用以下代码在 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)

它错误地说: “类型‘AWSServiceManager’的值没有成员‘setDefaultServiceConfiguration’”

为什么除了这一行之外一切都正常?怎么了?

最佳答案

AWSServiceManager 没有 defaultServiceConfiguration 的 setter 。

相反,你必须使用

AWSServiceManager.defaultServiceManager().defaultServiceConfiguration = defaultServiceConfiguration

这会起作用。

关于ios - 桥接 AWS SDK 上的 XCode 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34833712/

相关文章:

objective-c - 定义一个类来存储信息

ios - 从命令行+ iOS应用程序时,错误的无效体系结构“arm”

Xcode Instruments 使用大量内存。

ios - 在 .framework 中添加 Bridging-Header

ios - BLE 设备在应用程序终止时保持与 iPhone 的连接

ios - ShareKit - Flickr 集成 - 想要绕过(或至少自动填充)属性对话框

swift - 如何修改 Swift 中类型为 Any 的结构体对象?

swift - 在类中正确实现序列协议(protocol)

ios - 我可以在 Objective-C 中获取 Markdown 文件的内容吗?

ios - 在 PickerView 中设置行标题