Is there any possible way to use the pods which is coded in Obj C in Swift language.
Asked
Active
Viewed 631 times
2 Answers
2
You can directly use Objective c pod into your swift project
Example:
Step 1. Go to your project directory in your terminal and type pod init
. This will create a pod file, edit the pod file by writing pod 'Toast', '~> 4.0.0'
.
# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'
target 'ObjcPOD' do
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
pod 'Toast', '~> 4.0.0'
# Pods for ObjcPOD
end
Step 2. Run the command pod install
in the terminal which will install pod into your project and thus generating .xcodeworkspace file. Open that file and then write:
import UIKit
import Toast
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
self.view.makeToast("Toast Here")
}
}
Now you can run the app, done!

Community
- 1
- 1

Shubham Mishra
- 1,303
- 13
- 24
0
Just use use_frameworks! flag in the podfile before giving pod name that you want to install like this:
// Podfile
use_frameworks!
pod 'CoolObjectiveCLib'
for more detailed answer you can check @Vlad Papko answer here : How to use Objective-C Cocoapods in a Swift Project?

Moazzam
- 24
- 5
-
It's no longer required since `cocoapods 1.5.0`. Swift can use pods as static libs now. – user28434'mstep Nov 29 '18 at 09:06