Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

如何在 object-c 项目中使用 #67

Open
NaiShengYu opened this issue Oct 14, 2024 · 1 comment
Open

如何在 object-c 项目中使用 #67

NaiShengYu opened this issue Oct 14, 2024 · 1 comment

Comments

@NaiShengYu
Copy link

我想在 object-c 项目中使用,但是不知道具体使用方式

@wzxha
Copy link
Contributor

wzxha commented Oct 15, 2024

需要先使用不包含异步方法的 Swift 代码进行功能封装后,暴露给 objc 代码。
举个例子

MyAliyunpan.swift

import AliyunpanSDK

@objcMember
public class MyAliyunpan: NSObject {
  public func funcA() {
     Task {
        let client: AliyunpanClient = AliyunpanClient(.init(
            appId: "YOUR_APP_ID",
            scope: "YOUR_SCOPE"
        )
        await client.authorize(credentials: credentials)
        ...
     }
  }
}

MyAliyunpanObjc.m

#import <YOUR_MODULE_NAME/YOUR_MODULE_NAME.swift>

- (void)test {
  [MyAliyunpan new] funcA];
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants