1

Im accessing a variable inside a class of my pod. The members inside the class have internal access modifier. But cannot able to access the tenantURL from the networking class. Why this happens?

SDKCore class

public class SDKCore {

    public static let shared = SDKCore()

    var accessToken: String
    var tenantURL: String
    var clientSecret: String
    var appId: String

    init(accessToken: String, tenantUrl: String, clientSecret: String, appId: String) {
        self.accessToken = accessToken
        self.tenantURL = tenantUrl
        self.clientSecret = clientSecret
        self.appId = appId
    }

    static var getInstance: ApiClient = {
        return ApiClient()
    } ()
}

Networking class

class Networking {

    func performFileDownload(path: String, completionHandler: @escaping (ResultModel<DataResponse<Data>, Error>) -> Void) {
        let fileUrl = SDKCore.tenantURL + path

        alamofire.request(fileUrl)
            .responseData { (response) in
                switch response.result {
                case .success(_):
                    completionHandler(.success(response))
                case .failure(let error):
                    completionHandler(.failed(error))
                }
        }
    }

Use of unresolved identifier 'SDKCore'

Pod Directory structure

Vaisakh KP
  • 467
  • 1
  • 6
  • 25
  • 1
    Did you look at this thread? https://stackoverflow.com/questions/37138815/not-able-to-access-public-swift-class-through-framework – emrepun Jan 17 '19 at 13:43
  • 1
    You need to access instance properties through the `shared` instance (for which to be a true singleton, you need to make the initializer of `SDKCore` private) like `SDKCore.shared.tenantURL`. However, the error message should be resolved by the linked Q&A by emrepun. – Dávid Pásztor Jan 17 '19 at 13:44
  • I can able to access the pod class members through my project. But not able to access the same inside the pod. That is the different. – Vaisakh KP Jan 18 '19 at 04:34
  • I have checked pod's compile source also. but all these files are listed there? Can anyone help? – Vaisakh KP Jan 19 '19 at 10:06
  • are all files in the correct Target Membership? (right list in Xcode) – Phil Niedertscheider Jan 19 '19 at 17:39
  • Does the pod file have this target membership option? – Vaisakh KP Jan 20 '19 at 05:57

1 Answers1

1

If you look at your code, it clearly visible that tent tenantURL is instance variable not the class one,

SDKCore.shared.tenantURL

Also Try to clean your project and reinstall the pods

Ajay Singh Mehra
  • 1,313
  • 9
  • 19