Search code examples
swiftxcodexcframework

XCFramework asking for instance of self when not specified


I'm trying to create a Framework that I can use across platforms. I have successfully added the framework to a test app and this is what the test framework looks like. Quite simple, all I want to do is import the framework and call HelloComputer.getHello() and get hello in return.

import Foundation

public class HelloComputer {

    public func getHello() -> String {

        return "hello world"

    }
}

But when I import the framework this is what happens

enter image description here

Am I missing something? Why is it asking for a instance of its self?


Solution

  • You declared getHello() as an instance method. Either call it like HelloComputer().getHello() or define it as a class method:

    public class func getHello() -> String {