0

Scenario: I had built a Swift <-- package simple App that is working.
Now I'm trying to convert this to a Objective-C <--- package app.

Question #1: How to I formally import the package?
I've read to use the '@import' vs the older '#import'.

Now I'm getting the "'init'isn't available".

enter image description here

Here's the package ("RicPackage.swift"):

import Foundation

public struct RicStruct {
    public private(set) var text = "Hello, World!"

    public init() {
    }
    
    public func sayHello() -> String {
        "Hello Ric!"
    }
}

public class RicClass: NSObject {
    @objc public var msg = "Mother has a feeling, I might be too appealing."
    @objc public let text = "Hello Everybody!"
    
    
    public init(msg: String) {
        if msg.isEmpty {
            self.msg = "Hello Ric!"
        }
    }
  
    public func sayHello() {
            print(text)
        }
    
    public func doSomething() {
        print("Inside doSomething()")
    }
}

enter image description here

I want to a least do something simple like:

RicClass *ricClass = [[RicClass alloc] init];
[ricClass sayHello];
Frederick C. Lee
  • 9,019
  • 17
  • 64
  • 105

1 Answers1

1

I don't see init() in your Swift class, if you are trying to call [[RicClass alloc] init] add init in your swift class:

 public override init() {
        
    }

You can only call initWithMsg for now with your current swift class:

[[RicClass alloc] initWithMsg:@""]
RTXGamer
  • 3,215
  • 6
  • 20
  • 29