首页 > 解决方案 > Cannot access Swift Framework in Objective-C

问题描述

Create Swift Framework ,

Geolens.swift

enter image description here

When i am trying to access in Objective-C project , cannot call 2 methods

createuser & startSessionForUser

enter image description here

Getting error like this

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

Getting error adding @objc

标签: swiftobjective-c-blocksswift-framework

解决方案


Your problem is in errorCode: Int? in UserCompletionBlock.

Int is value type, and Objective C cannot represent Optional of value type, only reference types such as class will.

So you have to either:

  1. get rid of optionality
  2. use reference type, such as NSNumber or your own wrapper
  3. drop this parameter completely

推荐阅读