aws sdk for mac os x application development [closed]

耗尽温柔 提交于 2019-12-02 23:31:54

Judging by a discussion on this topic in the AWS Developer Forums, there doesn't seem to be an official AWS SDK for MacOS X yet, but the iOS version is close to useable. One contributor to that thread has posted a modified version that allegedly works on MacOS X for at least some of the services. I don't have any personal experience with it, but it seems worth a look.

I've created a fork of the AWS iOS SDK which can be built and used for Mac OS X development. Check it out: https://github.com/amberdixon/aws-sdk-ios. In the readme, I've included instructions on how to build the Mac OS X version of the AWS iOS SDK framework. The tomandersen repo appears to use a much older version of the iOS SDK, the version I've created is a bit more current.

jab

Following on a previous answer, I forked and modified v2.2 of the AWS SDK for iOS so it now builds for Mac OS X (tested in Yosemite 10.10.3): https://github.com/johnabender/aws-sdk-ios Also checkout the tvos branch!

They provide a command-line tool to package the SDK components as .framework objects. Run Scripts/SdkPackage.sh AWSS3, and it will build the S3 framework and any dependencies. Run Scripts/Package.sh to build all the frameworks. The built frameworks wind up in the root/build of your AWS SDK directory if you build them all.

But yikes, their documentation is awful. For example, if you want to use an access key instead of a Cognito identity, you have to go through the code and figure out how (at least it's possible!). Want to list an S3 bucket's contents? Good luck. Most of the required classes aren't even listed in the documentation. And you'll have to include libz.dylib in your project to get it to build with the S3 SDK - they don't tell you that, either.

Anyway, here's some code to help anyone get started:

// This is helpful, also basically undocumented.
AWSLogger.defaultLogger().logLevel = .Verbose

let credentials = AWSStaticCredentialsProvider(accessKey: accessKeyId, secretKey: secretAccessKey)
let config = AWSServiceConfiguration(region: AWSRegionType.USWest2, credentialsProvider: credentials)

let listRequest = AWSS3ListObjectsRequest()
listRequest.bucket = "mybucket"
listRequest.prefix = "folder/"

// The key name allows you to set up multiple, global S3 configurations
// -- in case you'd ever want to do that, in violation of OO programming principles.
// But there's no way to make S3 requests using only a local config.
AWSS3.registerS3WithConfiguration(config, forKey: "s3")

AWSS3.S3ForKey("s3").listObjects(listRequest).continueWithBlock { (task: AWSTask!) -> AnyObject! in
    if task.error != nil {
        NSLog("error %@", task.error)
    }
    if task.result != nil {
        NSLog("finished %@", task.result!.description)
    }
    return nil
}

As Caleb mentioned: There is no official AWS SDK for OS X.

The easiest way to accomplish S3 file upload is using ASIHTTPRequest. It's a wrapper for CFNetwork, which is easy to use. A drawback is no ARC support, so you have to handle memory management on your own …

I needed the AWS SDK for Mac to support prepopulating a db for my iOS app and was amazed that it didn't exist (considering how trivial it would be to produce as would be so similar to the iOS version). I downloaded the github MacOS SDKs mentioned by Amber above and the one mentioned in the AWS link above. However neither built straight off so I decided to modify the iOS SDK myself so I could understand what the process was. Here are the steps that I went through to get DynamoDB working in XCode 5.0.2 on MacOS 10.9:

1.Download the iOS AWS 1.7.0 SDK, duplicate the folder and rename the folder to aws-MacOS-sdk-1.7.0 (a small amount of conditional compilation and if/else in the build script would do away with this step)

2.Modify src/Scripts/Framework.sh - this is the build tool for all the AWS frameworks - Replace all four xcodebuild lines (30-39) with:

`xcodebuild -configuration Release -project "${PROJECT}.xcodeproj" -target "${PROJECT}" -sdk macosx10.9`
  • Replace the lipo line (82-87) with:

    FRAMEWORK_INPUT_MAC_FILES="build/Release/lib${PROJECT}.a" cp "$FRAMEWORK_INPUT_MAC_FILES" "$FRAMEWORK_DIR/Versions/Current/$FRAMEWORK_NAME"

3.In the src folder there is an XCode project per framework, for each one you need:

  • Change Project's Base SDK to latest OS X
  • Change FTarget's Framework's SDKROOT to macosx10.9
  • Ensure current scheme is set to Framework and build
  • Fix compiler errors (I had a bunch of problems to do with @property, had to replace <UIKit/UIKit.h> with <Cocoa/Cocoa.h> here and there, and [[UIDevice currentDevice] systemName] with [[NSProcessInfo processInfo] operatingSystemVersionString]

To get DynamoDB working I had to build four frameworks - it was fairly painless

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!