Reputation: 138
I'm developing an ecommerce iOS app in swift. I want to integrate PayUMoney iOS SDK into my project. Only Objective-C SDK is there. All SO questions, tutorials and documentations are in Objective-C only. Is there any way to integrate this SDK into swift project? Please help me.
Upvotes: 2
Views: 2125
Reputation: 4755
To integrate Obj-C libraries into a Swift Project all you have to do is use a so-called Bridging Header. Those literally work as bridge between the Obj-C code and the Swift code. Here is an exact representation from the Apple Docs:
Basically what this does it let's Swift access everything through the one header file and for Obj-C it generates a .m file with all methods and other code.
File -> iOS -> Source -> CocoaTouch -> UIViewcontroller
and then as language select Objective-C. You can name it yourNewlyCreatedClass
for example.
whatever you want as we'll later delete it.#import
"yourNewlyCreatedClass.h"
and replace it with #import
<PayUMoney/PayUMoney.h>
or whatever the framework is called.To finish up, you can now delet the two created classes from before. Simply select yourNewlyCreatedClass.h
and yourNewlyCreatedClass.m
and you're good to go.
Congrats, now you can access any of the methods you see in their docs through simply typing them in your swift file.
For further reference, please advise the Apple Docs found here. Images were used from the official Apple Docs.
Hope that helps, Julian
Upvotes: 2