I need to develop an application for MAC OS X, which will be uploading the chosen files to amazon web services. But for that I need aws sdk for mac. I haven't found any on the web. Is it possible to modify the AWS SDK for iOS so it can be used for Mac?
我需要为MAC OS X开发一个应用程序,该应用程序将选择的文件上传到amazon web services。但是我需要aws sdk给mac,我还没有在网上找到。是否有可能修改AWS SDK以供iOS使用?
Also, the AWS SDK documentation doesn't explain how to upload files to S3. Does anyone have an example of how to do this?
此外,AWS SDK文档没有解释如何将文件上载到S3。有人有这样的例子吗?
Thanks
谢谢
5 个解决方案
#1
4
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.
从AWS开发者论坛上关于这个话题的讨论来看,似乎还没有一个官方的AWS MacOS X SDK,但是iOS版本已经接近可用了。该线程的一个贡献者发布了一个修改后的版本,据称该版本至少适用于某些服务的MacOS X。我对它没有任何个人经验,但它似乎值得一看。
#2
7
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.
我创建了AWS iOS SDK的一个分支,可以构建并用于Mac OS X开发。检查一下:https://github.com/amberdixon/aws-sdk-ios。在readme中,我介绍了如何构建AWS iOS SDK框架的Mac OS X版本。tomandersen的repo似乎使用的是iOS SDK的一个更老的版本,我创建的这个版本更现代一些。
#3
5
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!
按照之前的答案,我为iOS提供并修改了AWS SDK的v2.2,因此它现在为Mac OS X构建(在Yosemite 10.10.10.3中测试):https://github.com/johnabender/aws-sdk-ios也检查了tvos分支!
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.
它们提供一个命令行工具,将SDK组件打包为.framework对象。运行脚本/ SdkPackage。sh AWSS3,它将构建S3框架和任何依赖项。运行脚本/包。sh构建所有框架。构建的框架在构建AWS SDK目录的根/构建中结束。
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.
但是,哎呀,他们的文件太糟糕了。例如,如果您想使用一个访问键而不是一个Cognito标识,您必须通读代码并找出方法(至少这是可能的!)想要列出S3 bucket的内容吗?祝你好运。大多数必需的类甚至没有列在文档中。你必须包括libz。在您的项目中使用S3 SDK构建dylib——它们也没有告诉您这一点。
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
}
#4
0
As Caleb mentioned: There is no official AWS SDK for OS X.
正如Caleb提到的:OS X没有正式的AWS SDK。
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 …
实现S3文件上传的最简单方法是使用ASIHTTPRequest。它是CFNetwork的包装器,很容易使用。一个缺点是没有弧形支持,所以您必须自己处理内存管理……
#5
0
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:
我需要Mac的AWS SDK来支持为我的iOS应用预填充db,我惊讶地发现它根本不存在(考虑到它与iOS版本非常相似,生成它是多么微不足道)。我下载了上面Amber提到的github MacOS sdk和上面AWS链接中提到的那个。然而,这两种方法都不是直接构建的,所以我决定自己修改iOS SDK,这样我就能理解这个过程是什么。下面是我在MacOS 10.9的XCode 5.0.2中使用DynamoDB的步骤:
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)
1。下载iOS AWS 1.7.0 SDK,复制文件夹,将文件夹重命名为AWS - macos - SDK -1.7.0(少量的条件编译,构建脚本中的if/else将取消此步骤)
2.Modify src/Scripts/Framework.sh - this is the build tool for all the AWS frameworks - Replace all four xcodebuild lines (30-39) with:
2。修改src /脚本/框架。sh -这是所有AWS框架的构建工具——将所有四个xcodebuild行(30-39)替换为:
`xcodebuild -configuration Release -project "${PROJECT}.xcodeproj" -target "${PROJECT}" -sdk macosx10.9`
-
Replace the lipo line (82-87) with:
更换lipo线(82-87):
FRAMEWORK_INPUT_MAC_FILES="build/Release/lib${PROJECT}.a" cp "$FRAMEWORK_INPUT_MAC_FILES" "$FRAMEWORK_DIR/Versions/Current/$FRAMEWORK_NAME"
FRAMEWORK_INPUT_MAC_FILES = "构建/发布/ lib $ { }项目。“cp”美元FRAMEWORK_INPUT_MAC_FILES”“FRAMEWORK_DIR /版本/电流/ FRAMEWORK_NAME美元”
3.In the src folder there is an XCode project per framework, for each one you need:
3所示。在src文件夹中,每个框架都有一个XCode项目,您需要:
- Change Project's Base SDK to latest OS X
- 将项目的基础SDK更改为最新的OS X。
- Change FTarget's Framework's SDKROOT to macosx10.9
- 将FTarget的框架的SDKROOT更改为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]
-
修复编译错误(我有一堆问题要处理@property,必须替换
与 <可可 可可。h> 和[UIDevice currentDevice] systemName]和[[NSProcessInfo processInfo] operatingSystemVersionString]
To get DynamoDB working I had to build four frameworks - it was fairly painless
为了让DynamoDB正常工作,我必须构建四个框架——这相当简单
#1
4
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.
从AWS开发者论坛上关于这个话题的讨论来看,似乎还没有一个官方的AWS MacOS X SDK,但是iOS版本已经接近可用了。该线程的一个贡献者发布了一个修改后的版本,据称该版本至少适用于某些服务的MacOS X。我对它没有任何个人经验,但它似乎值得一看。
#2
7
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.
我创建了AWS iOS SDK的一个分支,可以构建并用于Mac OS X开发。检查一下:https://github.com/amberdixon/aws-sdk-ios。在readme中,我介绍了如何构建AWS iOS SDK框架的Mac OS X版本。tomandersen的repo似乎使用的是iOS SDK的一个更老的版本,我创建的这个版本更现代一些。
#3
5
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!
按照之前的答案,我为iOS提供并修改了AWS SDK的v2.2,因此它现在为Mac OS X构建(在Yosemite 10.10.10.3中测试):https://github.com/johnabender/aws-sdk-ios也检查了tvos分支!
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.
它们提供一个命令行工具,将SDK组件打包为.framework对象。运行脚本/ SdkPackage。sh AWSS3,它将构建S3框架和任何依赖项。运行脚本/包。sh构建所有框架。构建的框架在构建AWS SDK目录的根/构建中结束。
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.
但是,哎呀,他们的文件太糟糕了。例如,如果您想使用一个访问键而不是一个Cognito标识,您必须通读代码并找出方法(至少这是可能的!)想要列出S3 bucket的内容吗?祝你好运。大多数必需的类甚至没有列在文档中。你必须包括libz。在您的项目中使用S3 SDK构建dylib——它们也没有告诉您这一点。
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
}
#4
0
As Caleb mentioned: There is no official AWS SDK for OS X.
正如Caleb提到的:OS X没有正式的AWS SDK。
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 …
实现S3文件上传的最简单方法是使用ASIHTTPRequest。它是CFNetwork的包装器,很容易使用。一个缺点是没有弧形支持,所以您必须自己处理内存管理……
#5
0
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:
我需要Mac的AWS SDK来支持为我的iOS应用预填充db,我惊讶地发现它根本不存在(考虑到它与iOS版本非常相似,生成它是多么微不足道)。我下载了上面Amber提到的github MacOS sdk和上面AWS链接中提到的那个。然而,这两种方法都不是直接构建的,所以我决定自己修改iOS SDK,这样我就能理解这个过程是什么。下面是我在MacOS 10.9的XCode 5.0.2中使用DynamoDB的步骤:
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)
1。下载iOS AWS 1.7.0 SDK,复制文件夹,将文件夹重命名为AWS - macos - SDK -1.7.0(少量的条件编译,构建脚本中的if/else将取消此步骤)
2.Modify src/Scripts/Framework.sh - this is the build tool for all the AWS frameworks - Replace all four xcodebuild lines (30-39) with:
2。修改src /脚本/框架。sh -这是所有AWS框架的构建工具——将所有四个xcodebuild行(30-39)替换为:
`xcodebuild -configuration Release -project "${PROJECT}.xcodeproj" -target "${PROJECT}" -sdk macosx10.9`
-
Replace the lipo line (82-87) with:
更换lipo线(82-87):
FRAMEWORK_INPUT_MAC_FILES="build/Release/lib${PROJECT}.a" cp "$FRAMEWORK_INPUT_MAC_FILES" "$FRAMEWORK_DIR/Versions/Current/$FRAMEWORK_NAME"
FRAMEWORK_INPUT_MAC_FILES = "构建/发布/ lib $ { }项目。“cp”美元FRAMEWORK_INPUT_MAC_FILES”“FRAMEWORK_DIR /版本/电流/ FRAMEWORK_NAME美元”
3.In the src folder there is an XCode project per framework, for each one you need:
3所示。在src文件夹中,每个框架都有一个XCode项目,您需要:
- Change Project's Base SDK to latest OS X
- 将项目的基础SDK更改为最新的OS X。
- Change FTarget's Framework's SDKROOT to macosx10.9
- 将FTarget的框架的SDKROOT更改为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]
-
修复编译错误(我有一堆问题要处理@property,必须替换
与 <可可 可可。h> 和[UIDevice currentDevice] systemName]和[[NSProcessInfo processInfo] operatingSystemVersionString]
To get DynamoDB working I had to build four frameworks - it was fairly painless
为了让DynamoDB正常工作,我必须构建四个框架——这相当简单