Reputation: 497
This is a custom cocoapod which connect with Alamofire. How can i access Alamofire pod imported in my code.
let SDKConnect = Networking()
class Networking {
var AFManager = Alamofire.SessionManager()
init() {
AFManager = {
let trustPolicies: [String: ServerTrustPolicy] = [ "example.com": .disableEvaluation ]
let AFConfig = URLSessionConfiguration.default
AFConfig.httpAdditionalHeaders = Alamofire.SessionManager.defaultHTTPHeaders
AFConfig.timeoutIntervalForRequest = 15
AFConfig.timeoutIntervalForResource = 15
let manager = Alamofire.SessionManager( configuration: URLSessionConfiguration.default, serverTrustPolicyManager: ServerTrustPolicyManager(policies: trustPolicies) )
return manager
}()
}
Use of unresolved identifier 'Alamofire'
Upvotes: 0
Views: 154
Reputation: 1069
I attached a given example and here is the guide on how to create it:
Project:
pod lib create WebConnnect
to create the initial project (go with the default answers).pod deintegrate
in the Examples
folder, to remove the initial dependencies from the Xcode workspaceWebConnect.podspec
:Pod::Spec.new do |s|
...
s.dependency 'Alamofire'
s.dependency 'SwiftyJSON'
end
Nimble
, Quick
, FBSnapshotTestCase
and Nimble-Snapshots
in the Podfile, as these are outdated by default anyway.pod install
and pod update
, to ensure the newest dependencies are installed.Code:
Rename the file ReplaceMe.swift
to Networking.swift
in the folder Development Pods/WebConnect
and make sure its Target Membership is the target WebConnect
.
Now add the following code to the file (it is basically yours, but I added the import of Alamofire):
import Alamofire
let SDKConnect = Networking()
class Networking {
var AFManager = Alamofire.SessionManager()
init() {
AFManager = {
let trustPolicies: [String: ServerTrustPolicy] = [ "example.com": .disableEvaluation ]
let AFConfig = URLSessionConfiguration.default
AFConfig.httpAdditionalHeaders = Alamofire.SessionManager.defaultHTTPHeaders
AFConfig.timeoutIntervalForRequest = 15
AFConfig.timeoutIntervalForResource = 15
let manager = Alamofire.SessionManager( configuration: URLSessionConfiguration.default, serverTrustPolicyManager: ServerTrustPolicyManager(policies: trustPolicies) )
return manager
}()
}
}
Download: Hosted by WeTransfer
Upvotes: 2
Reputation: 21808
In the .podspec
file of your custom pod add Alamofire
as a dependency, something like this:
spec.dependency 'Alamofire'
and then do pod repo push
, then pod update YourCustomPod
and then you'll be able to use Alamofire
Upvotes: 1