iSara
iSara

Reputation: 929

How to use an Objective-C based framework in Swift based project?

I have an Objective-C based cocoa pod framework. This framework has a class with XIP view controller. I want to access this controller from a Swift based project. The below code is Objective-C code. I need to use it in a Swift based project.

ViewController * viewController = [[ViewController alloc] initWithNibName:@“VController” bundle:nil];
viewController.delegate = self;
viewController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[vc presentViewController: viewController animated:true completion:nil];

Upvotes: 1

Views: 66

Answers (1)

iOS Geek
iOS Geek

Reputation: 4855

Its simple just follow some steps and you are able to do That

I have a project and I am using RIOInterface.h Obj-c in My swift project

Step 1- Just add Objective c file in Swift Project

I added RIOinterface.h and .mm in my project

enter image description here

Step 2 After when you will just drag and drop Obj-c Classes Now a popup will show as

enter image description here

-> Click Yes

Step 3- Now Import your Obj-C Header in bridging class created

enter image description here

Step 4- You are done with configuration steps Now, Time to use that class

as, I created a Object for that class

enter image description here

Now use it with that created object as below

enter image description here

You accessed your objective-C code in Swift

Upvotes: 1

Related Questions