Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Swift method not visible in objective C

I have project using Swift 3.2 and Objective-C compiling with Xcode Version 9.0 (9A235). It compiles fine in Swift 3.2. However, when I switch to Swift 4.0, the methods declared in Swift is no longer visible in Objective-C. The error is No visible @interface "UserAPI" declares the selector ...

enter image description hereenter image description here

like image 866
MobileDev Avatar asked Dec 23 '22 13:12

MobileDev


1 Answers

You should add @objc before your function like this.

@objc func doSomething() {
   //Some code goes here
}
like image 148
John Doe Avatar answered Jan 05 '23 00:01

John Doe