Using objc SDK in swift with Cocoapods
Add gem source when original sources unavailable
gem sources -a http://ruby.taobao.org/ deprecated
gem sources -a https://gems.ruby-china.com/
gem install cocoapods
Creating first Xcode project with cocoapods
- Create a normal Xcode project
- Add a
Podfile
file to the root of the project
platform :ios, '8.0'
pod 'AFNetworking', '~>2.5.4'
- Install pod
cd to the project and run
pod install
- Use the
xcworkspace
instead of thexcodeproj
- Most important procedure - Add
Brigding-Header
file- add a objective-c
.m
file to the project and accept XCode to create theproject-name-Bridging-Header.h
file for you. - then you can delete the
.m
file XCode created for you - import your target s public headers that you would like to expose to swift
#import <AFNetworking/AFNetworking.h>
- add a objective-c
- Then you can use the sdk in your project
let manager = AFHTTPRequestOperationManager()