Skip to content

No known class method for selector 'swiftMethod:' #4

@naninunenoy

Description

@naninunenoy

Xcode: 10.2
Swift Language Version: 4

スクリーンショット 2019-03-29 19 46 30

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions