Search code examples
swiftobjective-c-blocksswift-framework

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


Solution

  • 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