Skip to content

Commit

Permalink
修改readme介绍
Browse files Browse the repository at this point in the history
  • Loading branch information
duan007a committed Oct 26, 2018
1 parent 55419b8 commit 024161f
Show file tree
Hide file tree
Showing 4 changed files with 142 additions and 8 deletions.
55 changes: 49 additions & 6 deletions README-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

需要引入OSS iOS SDK framework。

您可以在MacOS系统中直接使用在本工程生成framwork
您可以在MacOS系统中直接使用本工程,选择对应的scheme为AliyunOSSSDK OSX,然后生成framwork

```bash
# clone工程
Expand All @@ -26,16 +26,16 @@ $ git clone [email protected]:aliyun/aliyun-oss-ios-sdk.git
$ cd aliyun-oss-ios-sdk

# 执行打包脚本
$ sh ./buildFramework.sh
$ sh ./buildiOSFramework.sh

# 进入打包生成目录,AliyunOSSiOS.framework生成在该目录下
$ cd Products && ls
```

注意:buildFramework.sh脚本生成的framework是支持i386,x86_64,armv7,arm64架构的版本,所以当您需要archive product时,需要直接使用工程文件生成只支持真机的framework版本。

在Xcode中,直接把framework拖入您对应的Target下即可,在弹出框勾选`Copy items if needed`

**注意:buildiOSFramework.sh脚本生成的framework是支持i386,x86_64,armv7,arm64架构的版本,所以当您需要archive product时,需要直接使用工程文件生成只支持真机的framework版本。**

### Pod依赖

如果工程是通过pod管理依赖,那么在Podfile中加入以下依赖即可,不需要再导入framework:
Expand Down Expand Up @@ -79,8 +79,6 @@ WWDC 2016开发者大会上,苹果宣布从2017年1月1日起,苹果App Stor

### 对于OSSTask的一些说明

**注意: 建议OSSClient的生命周期和应用程序的生命周期保持一致(如果您不希望这样,也可以在调用API时增加[task waitUntilFinished]以确保在task完成之前OSSClient不被释放)。**

所有调用api的操作,都会立即获得一个OSSTask,如:

```
Expand Down Expand Up @@ -129,6 +127,51 @@ client = [[OSSClient alloc] initWithEndpoint:endpoint credentialProvider:credent

```
**注意: 如果您的应用只用到一个[数据中心](https://help.aliyun.com/document_detail/31837.html)下的bucket,建议保持OSSClient实例与应用程序的生命周期一致(比如在Appdelegate.m的 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions])中进行初始化,如下所示:**
```objc
@interface AppDelegate ()
@property (nonatomic, strong) OSSClient *client;
@end
/**
* 获取sts信息的url,配置在业务方自己的搭建的服务器上。详情可见https://help.aliyun.com/document_detail/31920.html
*/
#define OSS_STS_URL @"oss_sts_url"
/**
* bucket所在的region的endpoint,详情可见https://help.aliyun.com/document_detail/31837.html
*/
#define OSS_ENDPOINT @"your bucket's endpoint"
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
// 初始化OSSClient实例
[self setupOSSClient];
return YES;
}
- (void)setupOSSClient {
// 初始化具有自动刷新的provider
OSSAuthCredentialProvider *credentialProvider = [[OSSAuthCredentialProvider alloc] initWithAuthServerUrl:OSS_STS_URL];
// client端的配置,如超时时间,开启dns解析等等
OSSClientConfiguration *cfg = [[OSSClientConfiguration alloc] init];
_client = [[OSSClient alloc] initWithEndpoint:OSS_ENDPOINT credentialProvider:credentialProvider clientConfiguration:cfg];
}
```

### STEP-2. 上传文件

这里假设您已经在控制台上拥有自己的Bucket。SDK的所有操作,都会返回一个`OSSTask`,您可以为这个task设置一个延续动作,等待其异步完成,也可以通过调用`waitUntilFinished`阻塞等待其完成。
Expand Down
49 changes: 47 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ This document mainly describes how to install and use the OSS iOS SDK. This docu

The OSS iOS SDK framework needs to be introduced.

You can use this project to directly generate a framework in MacOS :
You can use this AliyunOSSSDK.xcworkspace,and select scheme which named AliyunOSSSDK OSX to directly generate a framework in MacOS :

```bash
# Clone the project
Expand All @@ -26,7 +26,7 @@ $ git clone [email protected]:aliyun/aliyun-oss-ios-sdk.git
$ cd aliyun-oss-ios-sdk

# Run the packaging script
$ sh ./buildFramework.sh
$ sh ./buildiOSFramework.sh

# Enter the generated packaging directory where the AliyunOSSiOS.framework will be generated
$ cd Products && ls
Expand Down Expand Up @@ -123,6 +123,51 @@ client = [[OSSClient alloc] initWithEndpoint:endpoint credentialProvider:credent

```
**Notice:if your app's buckets only at one [data center](https://www.alibabacloud.com/help/doc-detail/31837.htm),we recommend you to keep the lifecycle of OSSClient's instance consistent with your app.the code below demonstrate the usage**
```objc
@interface AppDelegate ()
@property (nonatomic, strong) OSSClient *client;
@end
/**
* the url to fetch sts info,for detail please refer to https://help.aliyun.com/document_detail/31920.html
*/
#define OSS_STS_URL @"oss_sts_url"
/**
* the endpoint for OSS used in app, for detail please refer to https://help.aliyun.com/document_detail/31837.html
*/
#define OSS_ENDPOINT @"your bucket's endpoint"
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
// initialize OSSClient
[self setupOSSClient];
return YES;
}
- (void)setupOSSClient {
// initialize credential provider,which auto fetch and update sts info from sts url.
OSSAuthCredentialProvider *credentialProvider = [[OSSAuthCredentialProvider alloc] initWithAuthServerUrl:OSS_STS_URL];
// set config for oss client networking
OSSClientConfiguration *cfg = [[OSSClientConfiguration alloc] init];
_client = [[OSSClient alloc] initWithEndpoint:OSS_ENDPOINT credentialProvider:credentialProvider clientConfiguration:cfg];
}
```

### Step-2. Upload a file

Suppose that you have a bucket in the OSS console. An *OSSTask* will be returned after each SDK operation. You can configure a continuation for the task to achieve asynchronous callback. You can also use the *waitUntilFinished* to block other requests and wait until the task is finished.
Expand Down
46 changes: 46 additions & 0 deletions buildOSXFramework.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/bin/sh

PROJECT_NAME='AliyunOSSSDK'
TARGET_NAME="AliyunOSSSDK OSX"
SRCROOT='.'

# Sets the target folders and the final framework product.
FMK_NAME='AliyunOSSOSX'

# Install dir will be the final output to the framework.
# The following line create it in the root folder of the current project.
INSTALL_DIR=${SRCROOT}/Products/${FMK_NAME}.framework

# Working dir will be deleted after the framework creation.
WRK_DIR=./build
DEVICE_DIR=${WRK_DIR}/Release/${FMK_NAME}.framework

# -configuration ${CONFIGURATION}
# Clean and Building both architectures.
# xcodebuild -configuration "Release" -target "${FMK_NAME}" -sdk iphoneos clean build
# xcodebuild -configuration "Release" -target "${FMK_NAME}" -sdk iphonesimulator clean build
xcodebuild -configuration Release -workspace "${PROJECT_NAME}.xcworkspace" -scheme "${TARGET_NAME}" -sdk macosx clean build SYMROOT="${WRK_DIR}"

# Cleaning the oldest.
if [ -d "${INSTALL_DIR}" ]
then
rm -rf "${INSTALL_DIR}"
fi

mkdir -p ${SRCROOT}/Products

cp -LR "${DEVICE_DIR}" "${INSTALL_DIR}"


rm -r "${WRK_DIR}"

if [ -d "${INSTALL_DIR}/_CodeSignature" ]
then
rm -rf "${INSTALL_DIR}/_CodeSignature"
fi

if [ -f "${INSTALL_DIR}/Info.plist" ]
then
rm "${INSTALL_DIR}/Info.plist"
fi

File renamed without changes.

0 comments on commit 024161f

Please sign in to comment.