I have a struct in a framework called "MyFramework"
public struct ShipmentPackage:Encodable {
let package_code:String
let weight:Float
}
Then when I try to create a ShipmentPackage in another project/framework
import MyFramework
let onePackage = ShipmentPackage(package_code:"BX",weight:100)
I got an error message 'ShipmentPackage' initializer is inaccessible due to 'internal' protection level I come to this link https://forums.swift.org/t/public-struct-init-is-unexpectedly-internal/5028
I tried to change my code to following:
1st attempt:
public struct ShipmentPackage:Encodable {
let package_code:String
let weight:Float
public init(package_code:String,weight:Float){
self.package_code = package_code
self.weight = weight
}
}
2nd attempt:
public struct ShipmentPackage:Encodable {
public let package_code:String
public let weight:Float
public init(package_code:String,weight:Float){
self.package_code = package_code
self.weight = weight
}
}
Also I tried to changing around the package_code and weight to public, but none of above works, I got error messages when compile
<unknown>:0: error: 'init' is inaccessible due to 'internal' protection level
<unknown>:0: note: 'init' declared here
<unknown>:0: error: 'init' is inaccessible due to 'internal' protection level
Any hint would be appreciated!