4

As I developed the framework which is having both swift and objective c files.When I accessing the swift class in swift project it is working fine but when I tried to access the objective c class in swift i can't able to access and I also bridged the objective c file in swift project.can anyone help me to solve this above problem.

//swift project
import ObjCSwiftFramework

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        let callingswiftfile = SwiftFile() //calling the swift file 
       let callingobjectivecfile = ObjectiveCFile()//**Use of unresolved identifier 'ObjectiveCFile'**

    }

}


//Bridge file
#ifndef ObjCSwift_project_Bridging_Header_h
#define ObjCSwift_project_Bridging_Header_h
#import "ObjCSwiftFramework/ObjCSwiftFramework.h"
#endif

I also added the framework screen shot for your reference enter image description here

KAVIYA VENKAT
  • 337
  • 2
  • 17

2 Answers2

1

for using objective-c files in swift you need to us Bridging header and now just simply Import the class name in that as below

Name of bridging file is like AppName-Bidging-Header.h

enter image description here

Create a Bridging Header

https://mycodetips.com/ios/manually-adding-swift-bridging-header-1290.html

File will look like after adding and importing obj-c class

//
//  Use this file to import your target's public headers that you would like to expose to Swift.
//
#import "CardIO.h"
iOS Geek
  • 4,825
  • 1
  • 9
  • 30
0

you need to use bridging header. To know how to create a bridging header use below link

https://mycodetips.com/ios/manually-adding-swift-bridging-header-1290.html

sanjaykmwt
  • 586
  • 3
  • 19