unity-swift
unity-swift copied to clipboard
No known class method for selector 'swiftMethod:'
Xcode: 10.2 Swift Language Version: 4
@objc
attribute is required to call from obj-c source code in Swift4.
https://github.com/apple/swift-evolution/blob/master/proposals/0160-objc-inference.md
And Xcode 10.2 can only use Swift4 or later.
Please fix Exapmle.swift this way.
import Foundation
class Example : NSObject {
static func callUnityMethod(_ message: String) {
// Call a method on a specified GameObject.
UnitySendMessage("CallbackTarget", "OnCallFromSwift", message)
}
// !!Here!!
@objc static func swiftMethod(_ message: String) {
print("\(#function) is called with message: \(message)")
self.callUnityMethod("Hello, Unity!")
}
}
@naninunenoy Fixed this issue on my fork, currently have a pending pull request. https://github.com/richardschembri/unity-swift
@richardschembri, thank you fro the fix.