ios - How to integrate Cocoapods with a Swift project? -
as apple introduced swift, new programming language, wonder how can integrate existing objective-c libraries available via cocoapods?
cocoapods 0.36 , above introduces use_frameworks!
instruction implies bridging header not required importing objective-c pods in swift.
please find below full example using mbprogresshud , alamofire:
1. podfile
source 'https://github.com/cocoapods/specs.git' platform :ios, '8.3' use_frameworks! pod 'alamofire', '>= 1.2.2' # swift pod pod 'mbprogresshud', '>= 0.9.1' # objective-c pod
2. deletion
remove #imports bridging header or delete bridging header file if not need it. if choose latter possibility, not forget delete path (to deleted bridging header file) in xcode project configuration.
3. adding imports
add import mbprogresshud
and/or import alamofire
@ top of every swift files need these class(es).
4. fix enums if necessary
you're using bona fide frameworks, enums have moved in flight! might have line of swift fine bridging header this:
progresshud.mode = mbprogresshudmodeindeterminate
that has become this:
progresshud.mode = mbprogresshudmode.indeterminate
not big deal, pile of errors might lead astray have bigger problem if using lot of objective-c enums.
for information: guess (you have test sure) use_frameworks! instruction in podfile compatible xcode projects targeting ios >= 8.
Comments
Post a Comment