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!")
}
}
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.