1

I have some c++ files(with .mm extension) and some Swift files all in a project that is Objective-C.
I added bridging header in order to call Swift methods in the objective-C.
It is possible to make instance and use the c++ classes in Objective-C code. but I cannot use the C++ classes in the Swift Code.

   // Graph.h
   #import <Foundation/Foundation.h>
   #import <UIKit/UIKit.h>
    @interface Graph : NSObject

    - (id) init;
    -(void) setIsProccessingFrame:(BOOL)flag;

    @end


    // Swift
    @objc class VideoViewController:UIViewController {
       var graph: graph = Graph() ---> //Use of undeclared type 'Graph'
    }

Error: Use of undeclared type 'Graph'

I have another sample project that contains the Swift and .mm files. and these codes work there. I think that they cannot work here because the project is based on Objective-C.

I think that I need to import it but I don't know how to.

Fattaneh Talebi
  • 727
  • 1
  • 16
  • 42
  • 4
    Possible duplicate of [Interacting with C++ classes from Swift](https://stackoverflow.com/questions/35229149/interacting-with-c-classes-from-swift) – Gerriet Feb 05 '19 at 06:51
  • @Gerriet Thanks. I have another sample project that contains the Swift and .mm files. and these codes work there. I think that they cannot work here because the project is based on Objective-C – Fattaneh Talebi Feb 05 '19 at 07:02
  • 1
    Did you add the header import to the bridging header? – Cristik Feb 05 '19 at 07:21
  • @Cristik Thanks. I imported them in "Project-Bridging-Header" and the problem was resolved – Fattaneh Talebi Feb 05 '19 at 07:33

0 Answers0