通过pod引入七牛的OC库
https://github.com/qiniu/objc-sdk
pod "Qiniu", "~> 7.2"
创建桥接头部文件
注意:在项目的根目录创建!
import OC 库
#ifndef Qiniu_Brdging_Header_h
#define Qiniu_Brdging_Header_h
#import <QiniuSDK.h>
#endif /* Qiniu_Brdging_Header_h */
配置桥接头部文件
这一步非常的重要,不要配置错误哦
在 Swift 调用OC代码
import Foundation
class QiniuUtils {
func upload() {
let token = "从服务端SDK获取"
let upManger = QNUploadManager()
let data = "Hello World!".data(using: .utf8)
upManger?.put(data, key: "filename", token: token, complete: { (info, key, resp) in
print(info)
print(resp)
}, option: QNUploadOption.defaultOptions())
}
}