You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As Apple introduced Swift, their new programming language, you probably wonder how easily you can integrate it with existing Objective-C libraries that are available via CocoaPods.
You begin with creating a Podfile:
pod 'SOAPEngine', '~> 1.0.0'
and running pod install to install pods in your project.
Nice, so far so good. Cocoapods successfully integrated with Xcode project. All we need to do now is to import our pod header file into Swift project. How do you do that?
Definitely not by adding #import <SOAPEngine64/SOAPEngine.h> to a Swift file as it would result in this error:
Expected expression
Expected identifier in import declaration
To do so, you must create a new Objective-C header file, let’s call it Example-Bridging-Header.h, and add it to the project. Then, you need to set Objective-C Bridging Header for your target:
and finally add import statement to the bridge header:
#import <SOAPEngine64/SOAPEngine.h>
Now you can use your pods in Swift.
varsoap=SOAPEngine()
soap.userAgent ="SOAPEngine"
soap.actionNamespaceSlash =true
soap.version = VERSION_1_1
soap.responseHeader =true // use only for non standard MS-SOAP service
soap.setValue("param-value", forKey:"param-name")
soap.requestURL("https://www.my-web.com/my-service.asmx",
soapAction:"https://www.my-web.com/My-Method-name",
completeWithDictionary:{(statusCode :Int,
dict :[AnyHashable:Any]?)->Voidinvarresult:Dictionary= dict! asDictionaryprint(result)}){(error :Error?)->Voidinprint(error)}