I'm building a cocoa pod as a wrapper for a RESTAPI i have created a Swift file inside Class folder of the cocoa pod project.Inside the swift file i have added a Singleton pattern class and Protocol which conform to codable protocol. But when i try to access the singleton class function in Example application viewcontroller.swift file i get an error stating getCapsules is inaccessible due to internal protection.Even have made everything as public still I get this error.
Class folder file
import Foundation
class NetworkService
{
public let capsuleurl = URL(string: "https://api.spacexdata.com/v4/capsules")
public let session = URLSession(configuration: .default)
public func getCapsules(onCompletion :@escaping(Capsules) -> Void)
{
let task = session.dataTask(with: capsuleurl!) { (data, response, error) in
DispatchQueue.main.async {
do
{
let capsules = try JSONDecoder().decode(Capsules.self, from: data!)
onCompletion(capsules)
}
catch
{
print(error.localizedDescription)
}
}
}
task.resume()
}
}
public struct Capsule: Codable {
public let reuseCount, waterLandings, landLandings: Int
public let lastUpdate: String?
public let launches: [String]
public let serial: String
public let status: Status
public let id: String
public enum CodingKeys: String, CodingKey {
case reuseCount = "reuse_count"
case waterLandings = "water_landings"
case landLandings = "land_landings"
case lastUpdate = "last_update"
case launches, serial, status, id
}
}
public enum Status: String, Codable {
case active = "active"
case destroyed = "destroyed"
case retired = "retired"
case unknown = "unknown"
}
public typealias Capsules = [Capsule]
View controller.swift file in Example application
import UIKit
import KSBSpacexKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
NetworkService.sharedobj. //I get error here sometimes NetworkService also not show in autocomplete
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}

