A legacy project was done on Objective-c, where there is a tab view. A full new feature is required with a new tab which I want to implement on Swift. Right now there is no time to convert full project into Swift but the new feature is to be implemented on Swift. Can anyone guide me how can I implement the new feature in Swift just adding a new Tab on Objective-c UI.
Asked
Active
Viewed 406 times
2
-
This can achieved by using a bridge header class. http://stackoverflow.com/questions/24002369/how-to-call-objective-c-code-from-swift – Anirban iOS Dec 15 '16 at 05:26
-
http://stackoverflow.com/questions/24102104/how-to-import-swift-code-to-objective-c, refer this – KAR Dec 15 '16 at 05:29
1 Answers
2
You can confidently start using Swift
files in your Objective-C
project. There is no need to convert full project into Swift
You can follow below steps to use Swift
class in your project:
- Create new Controller Class in
Swift
. - It will pop up for
Bridge-Header
file, create it. - If you want to use any
Objective-C
class into yourSwift
file just import thatObjective-C
file into yourBridge-Header
. - If you want to use
Swift
class file into yourObjective-C
controller so import "ProjectName-Swift.h" into yourObjective-C
controller class.
important : "ProjectName-Swift.h"
would be Module name. If you have multiple targets in your project the use "TargetName-Swift.h"
Please follow below links: https://developer.apple.com/library/content/documentation/Swift/Conceptual/BuildingCocoaApps/MixandMatch.html