Sazzad Hissain Khan
Sazzad Hissain Khan

Reputation: 40257

iOS - Implementing UI on Objective-c and Swift together

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.

Upvotes: 2

Views: 429

Answers (1)

Dheeraj D
Dheeraj D

Reputation: 4451

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 your Swift file just import that Objective-C file into your Bridge-Header.
  • If you want to use Swift class file into your Objective-C controller so import "ProjectName-Swift.h" into your Objective-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

How to call Objective-C code from Swift

How to import Swift code to Objective-C

Upvotes: 2

Related Questions