ios - How to use Objective-C Cocoapods in a Swift Project? -


is there way can use cocoapod written in objective c in swift project using swift?

do make bridging header? , if so, can access objects, classes, , fields defined libraries in cocoapod in swift?

there lot of cocoapods out there written in objective c. know swift, , i'm wondering if there's way me still use cocoapods.

basic answer question yes, can use objective-c code built cocoapods.

more important question "how use such libs?"
answer on question depends on use_frameworks! flag in podfile:
let's imagine want use objective-c pod name coolobjectiveclib.

if pod file uses use_frameworks! flag:

// podfile use_frameworks! pod 'coolobjectiveclib' 

then don't need add bridge header files.
need import framework in swift source file:

// myclass.swift import coolobjectiveclib 

now can use classes presented in lib.

if pod file doesn't use use_frameworks! flag:

// podfile pod 'coolobjectiveclib' 

then need create bridging header file , import there necessary objective-c headers:

// myapp-bridging-header #import "coolobjectiveclib.h" 

now can use classes defined in imported headers.


Comments

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

mercurial graft feature, can it copy? -