-1

I'm trying to use some of my swift classes inside of my Objective C project. Before to do it, I have validated the ios versions.ç

I'm using Can't use Swift classes inside Objective-C

but, at the moment to update the MyProject-Bridging-Header.h with:

@import Foundation;


@objc public class myClass

I get the error:

Unexpected '@' in program Expected ';' after top level declarator

How can I fix this error to import my swift classes?

JESERRANO
  • 359
  • 1
  • 3
  • 8

1 Answers1

0

When you want to import swift classes say like (suppose in file named MySwift.swift to be dragged to the project)

@objc public class MyClass:NSObject {

}

inside an objective-c project , you shouldn't but it inside the bridge .h file but to only import this line

#import "ProjectName-Swift.h"

top of the .m file you use the class in

Shehata Gamal
  • 98,760
  • 8
  • 65
  • 87