swift - 无法在 Objective-C 中访问 Swift Framework

标签 swift objective-c-blocks swift-framework

创建 Swift 框架,

Geolens.swift

enter image description here

当我尝试访问 Objective-C 项目时,无法调用 2 个方法

创建用户 & startSessionForUser

enter image description here

出现这样的错误

Method cannot be marked @objc because the type of the parameter cannot be represented in Objective-C

Getting error adding @objc

最佳答案

您的问题在errorCode: Int?UserCompletionBlock .

Intvalue type , 和 Objective C不能代表 Optionalvalue type , 只有 reference types例如 class会的。

所以你必须:

  1. 摆脱可选性
  2. 使用引用类型,例如NSNumber或者你自己的包装
  3. 完全放弃这个参数

关于swift - 无法在 Objective-C 中访问 Swift Framework,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50734962/

相关文章:

ios - 重用findObjectsInBackgroundWithBlock方法: Array is nil

ios - 无法在 Objective-C 中使用 Swift 生成的共享框架

xcode - 添加从 IPA 中提取的 swift 框架

swift - MBProcessHud 未在 Alamofire 中快速加载

swift - UIPickerView pickerView(_ :titleForRow:forComponent:) method

iOS 8 Storyboard/主界面

ios - 自定义平面设计 UITabBar

ios - __block 没有 block 的存储类型?

ios - dispatch_sync 阻止我的 UI,我无法单击任何按钮

ios - Swift 框架 - 未找到 Objective-C header