创建 Swift 框架,
Geolens.swift
当我尝试访问 Objective-C 项目时,无法调用 2 个方法
创建用户
& startSessionForUser
出现这样的错误
Method cannot be marked @objc because the type of the parameter cannot be represented in Objective-C
最佳答案
您的问题在errorCode: Int?
在 UserCompletionBlock
.
Int
是value type
, 和 Objective C
不能代表 Optional
的 value type
, 只有 reference types
例如 class
会的。
所以你必须:
- 摆脱可选性
- 使用引用类型,例如
NSNumber
或者你自己的包装 - 完全放弃这个参数
关于swift - 无法在 Objective-C 中访问 Swift Framework,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50734962/