Reputation: 3795
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 ...
Upvotes: 4
Views: 4097
Reputation: 776
Or! Use @objcMembers if you'd like to expose the entire class to Objective-C
@objcMembers class MyClass {
func methodOne() {
// no @objc required!
}
func methodTwo() {
// no @objc required here either!
}
}
Upvotes: 2
Reputation: 717
You should add @objc before your function like this.
@objc func doSomething() {
//Some code goes here
}
Upvotes: 8